Setting MPMediaItem's artwork

I know I can retrieve an MPMediaItem's artwork by doing the following:

MPMediaItemCollection *collection;
/* Get media item collection here */
MPMediaItem *item = [[collection items] objectAtIndex:0];
MPMediaItemArtwork *artwork = [item valueForKey:MPMediaItemPropertyArtwork];

I would like to replace the artwork image with another. How would I accomplish this?

I tried the following but it doesn't work.

UIImage *newImage;
/* get image here */
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:newImage];
[item setValue:artwork forKey:MPMediaItemPropertyArtwork];

An run-time exception is thrown with the following message: this class is not key value coding-compliant for the key artwork.

Answers


MPMediaItems are immutable - you can't change anything in the iPod library using the API.

http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/iPodLibraryAccess_Guide/AboutiPodLibraryAccess/AboutiPodLibraryAccess.html#//apple_ref/doc/uid/TP40008765-CH103-SW9


Need Your Help

IllegalStateException in AudioTrack.play()

android illegalstateexception audiotrack

I am working on an App in which the user can touch the screen and depending on where he/she touches a certain tone is played. To achieve this I have the following code:

Detecting interactive shell within ksh ENV script

shell unix ksh

What's the preferred way to determine if a given ksh invocation is running an interactive shell?