1
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;

 NSAppleEventDescriptor *eventDescriptor;
 NSAppleScript *script ;
 NSString* source ;
 NSDictionary* errorDic ;

 source=@"tell application \"iTunes\" \n"
 @"set tname to name of track 1 of playlist 1 \n"
 @"set tartist to artist of track 1 of playlist 1 \n"
 @"set talbum to album of track 1 of playlist 1 \n"
 @"set ttime to time of track 1 of playlist 1 \n"
 @"set tbitrate to bit rate of track 1 of playlist 1 \n"
 @"set tsize to size of track 1 of playlist 1 \n"
 @"set trating to rating of track 1 of playlist 1 \n"
 @"end tell";

 script = [[NSAppleScript alloc] initWithSource:source];
 eventDescriptor = [script executeAndReturnError:&errorDic];
 NSString* frontUrl = [eventDescriptor stringValue];
 NSLog(frontUrl);

 /*NSAlert *alert = [[NSAlert alloc]init];
 [alert setMessageText:frontUrl];
 [alert runModal];
 [alert release];*/

 [pool release] ;

NSlog only display a track rating. How to get value of tname,tartist,talbum,etc ?'

Thanks in advance

1 Answer 1

1

Applescript returns the value of the last statement executed. In this case, that's trating. Put a statement at the end that contains all the values (say, a list).

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

2 Comments

I tried to change to tell application "iTunes" set mydata to get {persistent ID, name, artist, album} of track 1 of playlist 1 get mydata end tell but the result is null
Just return { tname, tartist, talbum, ttime, tbitrate, tsize, trating }. Once you get that working, you may want to try returning and handling a record instead of a list, so that you aren't relying on the indexes agreeing between the AppleScript code and the Cocoa code.

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.