I’m trying to apply Unsynchronized’s answer (Drawing waveform with AVAssetReader) while using ARC. There were only a few modifications required, mostly release statements. Many thanks for a great answer! I’m using Xcode 4.2 targeting iOS5 device.
But I’m getting stuck on one statement at the end while trying to invoke the whole thing.
Method shown here:
-(void) importMediaItem {
MPMediaItem* item = [self mediaItem];
waveFormImage = [[UIImage alloc ] initWithMPMediaItem:item completionBlock:^(UIImage* delayedImagePreparation){
[self displayWaveFormImage];
}];
if (waveFormImage) {
[self displayWaveFormImage];
}
}
On the call to initWithMPMediaItem I get the following error:
Automatic Reference Counting Issue. Receiver type 'UIImage' for instance message
does not declare a method with selector 'initWithMPMediaItem:completionBlock:'
Since I do have the method initWithMPMediaItem declared in the class header, I really don’t understand why I’m getting this error.
- (id) initWithMPMediaItem:(MPMediaItem*)item
completionBlock:(void (^)(UIImage* delayedImagePreparation))completionBlock;
Been trying to wrap my head around this for several hours now but to no avail. Is my method declaration wrong for this type of method? Thanks!
It looks like
initWithMPMediaItemshould be declared as an initializer forUIImage. So you should declare it inside aUIImagecategory in your header file: