0
您好我整合SpotifyLib CocoaLibSpotify iOS库17-20-26-630到我的项目。我打开它SPLoginViewController
使用波纹管方法: -Spotify EXC_BAD_EXE第二次点击登录按钮后关闭LoginViewController
-(void)OpenSpotify
{
NSError *error = nil;
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size]
userAgent:@"com.mycomp.spotify"
loadingPolicy:SPAsyncLoadingImmediate
error:&error];
if (error != nil) {
NSLog(@"CocoaLibSpotify init failed: %@", error);
abort();
}
[[SPSession sharedSession] setDelegate:self];
[self performSelector:@selector(showLogin) withObject:nil afterDelay:0.0];
}
-(void)showLogin
{
SPLoginViewController *controller = [SPLoginViewController loginControllerForSession:[SPSession sharedSession]];
controller.allowsCancel = YES;
//controller.view.frame=;
[self presentViewController:controller animated:YES completion:nil];
}
,第一时间出现Spotify Login
屏幕。之后,我点击取消按钮,并尝试再次打开登录屏幕,然后我崩溃EXC_BAD_EXE
在这条线。 sp_error createErrorCode = sp_session_create(&config, &_session);
UPDATE
我发现exet其中做大量的搜索之后得到BAD_EXC
在这种方法
+(void)dispatchToLibSpotifyThread:(dispatch_block_t)block waitUntilDone:(BOOL)wait {
NSLock *waitingLock = nil;
if (wait) waitingLock = [NSLock new];
// Make sure we only queue one thing at a time, and only
// when the runloop is ready for it.
[runloopReadyLock lockWhenCondition:1];
CFRunLoopPerformBlock(libspotify_runloop, kCFRunLoopDefaultMode, ^() {
[waitingLock lock];
if (block) { @autoreleasepool { block(); } }
[waitingLock unlock];
});
if (CFRunLoopIsWaiting(libspotify_runloop)) {
CFRunLoopSourceSignal(libspotify_runloop_source);
CFRunLoopWakeUp(libspotify_runloop);
}
[runloopReadyLock unlock]; // at hear when my debug poin reach after pass this i got bad_exc
if (wait) {
[waitingLock lock];
[waitingLock unlock];
}
}