0

I have been trying to work out the best way to accomplish this and every time I think I am on to something it doesn't seem to work in my situation.

If someone could point me in the right direction to an existing example or the correct google term I would be very grateful.

I am creating a Cocoa - Applescript Application in Xcode 5.

I have the basics in already, which so far prompts the user to select an audio track, the track is then played back in Quick Time and I have a button to return the current play time of the track, as it stands at the moment this returns the time to a variable of SMPTE ala.

tell application "QuickTime Player"
        set SMPTE to get current time of document 1
    end tell

My problem is what to do with the result of "SMPTE"

I would like to generate a list in a separate window with each button press updating a new row with the new returned value.

I have tried using a NSTableColumn but can't work out how to "auto fill" with each subsequent button press.

1 Answer 1

2

A very simplistic way.

Add an NSArrayController to the IB Objects.

Connect it to an outlet.
Select the TableView's TableColumn and go to it Bindings Inspector.

Bind it's Value to Array Controller

And name it's model key path as 'time'

In the TableColumn's Attributes Inspector. Set it's Title to 'time'

The code would be like this:

 property ArrayController :missing value



    on addTime_(sender) --clicked to add time
        tell application "QuickTime Player"
            set SMPTE to get current time of document 1
        end tell

        ArrayController's addObject:{|time|:SMPTE}
    end addTime_

The Button would need to be connected to the Action: addTime:


To remove an item:

Simply add a new button and connect it to the ArrayController's Remove Action method. ( By dragging the button's connection to the ArrayController object in IB and selecting remove: )


To Save the data to be able to see it on relaunch:

Select the ArrayController object in IB and go to it's bindings inspector. Bind it's Control Content's content Array to the 'Shared user defaults Controller'

And name it's model key path as 'theValues'


There is a very good intro tutorial here

And NSArrayController's Docs

Sign up to request clarification or add additional context in comments.

7 Comments

i received the error [__NSDictionaryM objectAtIndex:]: unrecognized selector sent to instance 0x618000055810 (error -10000)
Not in front of my Mac at the mo. But what _NSDictionaryM is it referring to?
I was able to follow the instructions above on a Mac I have here that only has Xcode 3.2.6 I only need to do a small change in the addObject syntax .e change the first colon to _() and place the {|time|:SMPTE} record/dict in side. Worked no prob. So this shows the code can work outside of my Mac. There must be something in your code outside of this. Set this up as a test app with just the code and instruction here before you add any of you own. See how that works.
My bad, I had the table and button still linked to some other property's from when I was trying stuff before, it was obviously confusing the poor thing..
One last thing. How would I go about exporting the final results as a .csv file?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.