gpt4 book ai didi

ios - Spotify EXC_BAD_EXE 在关闭 LoginViewController 后第二次点击登录按钮

转载 作者:行者123 更新时间:2023-11-29 03:21:06 24 4
gpt4 key购买 nike

您好,我将 SpotifyLib CocoaLibSpotify iOS Library 17-20-26-630 整合到我的项目中。我使用 Bellow 方法打开它的 SPLoginViewController:-

-(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_EXEsp_error createErrorCode = sp_session_create(&config, &_session);

enter image description here

更新

我找到了 BAD_EXC 所在的 exet

在这个方法中

+(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];
}
}

最佳答案

在进行大量搜索后,我得到了解决方案,我检查 session 是否已经存在,然后我将 if 条件设置为:-

-(void)OpenSpotify
{

SPSession *session = [SPSession sharedSession];
if (!session) {
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;
[self presentViewController:controller animated:YES completion:nil];
}

现在没有崩溃并且工作正常。

关于ios - Spotify EXC_BAD_EXE 在关闭 LoginViewController 后第二次点击登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21086126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com