As you may know, right after you finish syncing your phone, if you open up the iPod app you will notice it says 'updating library' for a few seconds before you can view your music. Well, I've discovered that performing an MPMediaQuery during this span results in 0 songs being returned, and my app crashing.
My root view is a table view with all the user's playlists. So you launch my app, a splash screen appears for a few seconds, and then the populated table pops up. I do all my work for querying the library in viewDidLoad(). This is no issue, unless you try to launch my app right after a sync, in which case it will crash. Try to open it up again a few seconds later, no problem (cause the iPod library updated).
What can I do to detect this condition and have my program wait until the library is finally available? I've tried a bunch of different things, such as registering for the library change notification, waiting until the library's lastModifiedDate stops changing, and a loop that keeps querying until it get's something...but none of these have worked for me...it's like the iPod can't update while my app is waiting for it to. Perhaps because I'm doing everything on the main thread? Or does the fact I'm doing it in viewDidLoad matter?
If someone knows how to solve this problem please let me know!
My root view is a table view with all the user's playlists. So you launch my app, a splash screen appears for a few seconds, and then the populated table pops up. I do all my work for querying the library in viewDidLoad(). This is no issue, unless you try to launch my app right after a sync, in which case it will crash. Try to open it up again a few seconds later, no problem (cause the iPod library updated).
What can I do to detect this condition and have my program wait until the library is finally available? I've tried a bunch of different things, such as registering for the library change notification, waiting until the library's lastModifiedDate stops changing, and a loop that keeps querying until it get's something...but none of these have worked for me...it's like the iPod can't update while my app is waiting for it to. Perhaps because I'm doing everything on the main thread? Or does the fact I'm doing it in viewDidLoad matter?
If someone knows how to solve this problem please let me know!