spotify/cocoalibspotify — Issue #34: Notification of "loaded" property of SPAlbumBrowse is too early for subsequent browse
Author: mattlevy
Created: 2012-01-12 15:57:58+00:00
State: open

If you add an observer on the "loaded" property of an SPAlbumBrowse, the first time you browse an album, the notification comes after the tracks are put in the "tracks" property of the SPAlbumBrowse object.

If you do another browse on the same album and observe the "loaded" property, the notification comes before the "tracks" array is loaded. I looked at the code in SPAlbumBrowse. It looks like in the function void albumbrowse_complete (sp_albumbrowse *result, void *userdata) the "loaded" property is being set at the beginning instead of using willChangeValueForKey: followed by didChangeValueForKey:

The result is that you get an empty array when you call the tracks method. But the "copyrights" property is set after the tracks array, so if I observe that property I get the notification after the tracks array has been created and filled in. I have a feeling that the first time you browse the album, sp_albumbrowse_is_loaded returns false at the beginning of albumbrowse_complete. But every subsequent time, it returns true, which is why the notification isn't sent before the tracks array is created.