Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Avicenna

macrumors member
Original poster
Jul 16, 2009
89
0
Here is a typical iTunes playerInfo notification:

Code:
2011-02-25 08:42:26.583 Demo[472:a0f] {
    Album = "Doo-Wops & Hooligans (Deluxe Version)";
    "Album Artist" = "Bruno Mars";
    "Album Rating" = 0;
    "Album Rating Computed" = 1;
    Artist = "Bruno Mars";
    "Artwork Count" = 1;
    "Disc Count" = 1;
    "Disc Number" = 1;
    Genre = Pop;
    "Library PersistentID" = 1734896675364731040;
    Location = ****
    Name = "Just the Way You Are (feat. Lupe Fiasco) [Remix] {Bonus Track}";
    PersistentID = 7070657166844949486;
    "Play Count" = 0;
    "Play Date" = "1904-01-01 00:00:00 -0500";
    "Player State" = Playing;
    "Playlist PersistentID" = "-7222080182103823525";
    "Rating Computed" = 1;
    "Skip Count" = 0;
    "Skip Date" = "1904-01-01 00:00:00 -0500";
    "Store URL" = "itms://itunes.com/link?n=Just%20the%20Way%20You%20Are%20(feat.%20Lupe%20Fiasco)%20%5BRemix%5D%20%7BBonus%20Track%7D&an=Bruno%20Mars&pn=Doo-Wops%20%26%20Hooligans%20(Deluxe%20Version)";
    "Total Time" = 238524;
    "Track Count" = 12;
    "Track Number" = 11;
    Year = 2010;
}
I want to compare the "Player State" 's object. But the object represented by the key "Player State" is not a string so how can I compare with say a state that represents Player Stopped ?

Something like this"

if ([information objectForKey:mad:"Player State"] isEqualToString @"Stopped"]) {
NSLog(@"Stopped!");
}


but [information objectForKey:mad:"Player State"] is not a string so I know it won't work.

Thanks.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,764
8,463
A sea of green
How did you generate the posted output?

I was probably code that's something like this:
Code:
NSLog( @"%@", information );

Next, think about what code you'd write if you wanted to NSLog
[information objectForKey:mad:"Player State"].

Now think about what code you'd write if you wanted an NSString whose contents is the same as what's logged (hint: NSString stringWithFormat:).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.