I have the following code on my AlbumViewController.h
@property MPMediaItemCollection *album;
And on my .m I use this property like this:
MPMediaItem *item = [[_album.items objectAtIndex:i] representativeItem];
On Xcode 6.0 this code compiles just fine, but on Xcode 7.0 I keep getting the "No visible interface" error.
Does anybody knows how to handle this?
You simply want:
MPMediaItem *item = _album.items[i];
The items
method of MPMediaItemCollection
returns an NSArray
of MPMediaItem
objects.
The representativeItem
property is a property of MPMediaItemCollection
, not MPMediaItem
, hence the error.
The code compiled on Xcode 6 because objectAtIndex:
returns an id
and you can call any method on an id
. With Xcode 7 (really iOS 9), the array is defined as being an array of type MPMediaItem
so the compiler now knows the type in the array and better error checking can be performed at compile time.
BTW - even though the code compiled under Xcode 6, it would have crashed at runtime.