Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query from ipod Library #36

Closed
davidAgo4g opened this issue Sep 15, 2012 · 2 comments
Closed

Query from ipod Library #36

davidAgo4g opened this issue Sep 15, 2012 · 2 comments

Comments

@davidAgo4g
Copy link

Hi i'm trying to make a query and to get all the metadata from the iPod library. So following the reference:

MPMediaQuery *everything = [[MPMediaQuery alloc] init];
NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery) {
      NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
      NSLog (@"%@", songTitle);
}

But only if i compile with theos this piece of code crash on '-(id)valueForProperty'. Why? Which file should i include? (Already added the MediaPlayer framework, and included with #import).

@theiostream
Copy link
Collaborator

It doesn't crash because of theos. It crashes because of your faulty code.

MPMediaQuery is not meant to be initialized by yourself. You should get an existing query using one of its class methods documented at its class reference. Since you mean to get all songs, I'd go with calling +[MPMediaQuery songsQuery].

Now, why does it crash? [everything items] probably returns an empty or nil array, which you crash when trying to iterate through.

Now, just to end, here's a motto for you: INCLUDING FILES DOES NOT CHANGE YOUR RUNTIME BEHAVIOR, BUT YOUR COMPILING BEHAVIOUR.

If I misunderstood your question and am giving a complete out of context answer, please let me know. :P

-- theiostream.

@theiostream
Copy link
Collaborator

Due to the lack of response and this question not being related to theos in any way: Even though this one might have not been completely been solved for the asker, it doesn't belong here anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants