FROM : Jonathan 'Wolf' Rentzsch
DATE : Sun Mar 02 06:06:54 2008
On Mar 1, 2008, at 7:28 PM, Hannes Petri wrote:
> iTunesApplication *iTunes = [[SBApplication alloc]
> initWithBundleIdentifier:@"com.apple.iTunes"];
> iTunesTrack *currentTrack = [iTunes currentTrack];
>
> if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
> …
> }
>
> The problem is, that the class of the object returned is _always_
> iTunesTrack, and not iTunesFileTrack, as i expect it to be. If i run
> the following applescript code:
>
> tell application "iTunes" to current track
>
> I get a "file track", which makes it possible to fetch the path
> using the "location" attribute. If I, in the ObjC example, try
> [currentTrack location], I'm told that it doesn't respond to that
> selector.
> I have made certain that the object is of class iTunesTrack by
> typing 'po [currentTrack class]' in gdb.
I ran into the same thing -- Scripting Bridge may play games
isKindOfClass: that bite us. My work-around is to test by class name:
if ([[track className] isEqualToString:@"ITunesURLTrack"]) { /* ... */ }
| Jonathan 'Wolf' Rentzsch http://rentzsch.com
| Red Shed Software http://redshed.net
| "better" necessarily means "different"
DATE : Sun Mar 02 06:06:54 2008
On Mar 1, 2008, at 7:28 PM, Hannes Petri wrote:
> iTunesApplication *iTunes = [[SBApplication alloc]
> initWithBundleIdentifier:@"com.apple.iTunes"];
> iTunesTrack *currentTrack = [iTunes currentTrack];
>
> if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
> …
> }
>
> The problem is, that the class of the object returned is _always_
> iTunesTrack, and not iTunesFileTrack, as i expect it to be. If i run
> the following applescript code:
>
> tell application "iTunes" to current track
>
> I get a "file track", which makes it possible to fetch the path
> using the "location" attribute. If I, in the ObjC example, try
> [currentTrack location], I'm told that it doesn't respond to that
> selector.
> I have made certain that the object is of class iTunesTrack by
> typing 'po [currentTrack class]' in gdb.
I ran into the same thing -- Scripting Bridge may play games
isKindOfClass: that bite us. My work-around is to test by class name:
if ([[track className] isEqualToString:@"ITunesURLTrack"]) { /* ... */ }
| Jonathan 'Wolf' Rentzsch http://rentzsch.com
| Red Shed Software http://redshed.net
| "better" necessarily means "different"
| Related mails | Author | Date |
|---|---|---|
| Hannes Petri | Mar 2, 02:28 | |
| Jonathan 'Wolf' Re… | Mar 2, 06:06 | |
| has | Mar 2, 13:05 | |
| Steven Degutis | Mar 2, 13:54 | |
| has | Mar 3, 00:02 | |
| Adam P Jenkins | Mar 3, 00:16 | |
| Adam P Jenkins | Mar 3, 00:40 | |
| has | Mar 3, 01:44 | |
| Jens Alfke | Mar 3, 07:32 | |
| has | Mar 3, 16:21 | |
| Steven Degutis | Mar 3, 16:27 | |
| Christopher Nebel | Mar 3, 21:22 | |
| has | Mar 3, 22:45 |






Cocoa mail archive

