开发者

AVFoundation iOS 5

开发者 https://www.devze.com 2023-04-13 01:11 出处:网络
My apps runing on the appstore are using mp3 and video files that don\'t work since iOS5 update. I\'ve installed xcode 4.2 and...

My apps runing on the appstore are using mp3 and video files that don't work since iOS5 update.

I've installed xcode 4.2 and... When I test in the iPhone 5 Simulator or device I get the following error (for audio or video files):

Error loading 
System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioI开发者_如何学CPCPlugIn:  
dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): 
Symbol not found: ___CFObjCIsCollectable
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

When I try this in the iPhone 4.3 simulator or device it does not crash ..

I've cleaned and re import the frameworks involved but it seems to be that kind of error

Note: My apps don't use any security.

Could you help?


I just have found an answer here.

If your app crashes here, disable All Exceptions in XCode 4 Breakpoints Tab. Maybe it's SDK bug.


Try to make your player a retained property. I experienced the same and because I declared my player locally I think ARC retained as soon as the method in which I declared the player ran out of scope.

Make player a retained property

@property (strong)AVAudioPlayer *player;

Remember to set the delegate (self.player.delegate = self) and use the delegate's methods to clean up:

-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)playedSuccessfully {
    self.player = nil;
}


I found the solution: NSURL instead of NSString:

NSURL *chemin = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MySound.wav", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
AVAudioPlayer* mySound = [[AVAudioPlayer alloc] initWithContentsOfURL:chemin error:&error];
mySound.delegate = self;
[chemin release];
[mySound Play];


I had the same error, but my code wasn't different from yours. I don't really need anything in the Security framework, but adding that framework to my project fixed this issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消