我已将Spotify从Beta6升级到Beta9。支持升级的必要更改之一是canHandleURL方法签名。 Beta6签名是:
canHandleURL: withDeclaredRedirectURL:
新签名将删除withDeclaredRedirectURL。但是,当我尝试使用appDelegate中的新签名以下列方式执行该方法时:
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if ([[SPTAuth defaultInstance] canHandleURL:url]) {
[[SPTAuth defaultInstance]
handleAuthCallbackWithTriggeredAuthURL:url callback:^(NSError *error, SPTSession *session) {
if (error != nil) {
...
return;
}
// Save the session info
...
}];
return YES;
}
...
return NO;
}
错误如下:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFString hasPrefix:]: nil argument'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112eeec65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000112b87bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000112eeeb9d +[NSException raise:format:] + 205
3 CoreFoundation 0x0000000112e0ee00 -[__NSCFString hasPrefix:] + 96
4 MyAPP 0x000000010fa64c0a -[SPTAuth _canHandleURL:withDeclaredRedirectURL:] + 143
5 MyAPP 0x000000010fa64c7e -[SPTAuth canHandleURL:] + 82
6 MyAPP 0x000000010f9e8c09 -[myAppDelegate application:openURL:sourceApplication:annotation:] + 73
7 UIKit 0x0000000111159cd0 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 144
8 UIKit 0x0000000111159c31 -[UIApplication _applicationOpenURL:payload:] + 333
9 UIKit 0x0000000111162328 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:] + 2350
10 UIKit 0x0000000111165e71 __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 196
11 UIKit 0x0000000111165d9e -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 349
12 UIKit 0x00000001111507fa -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 486
13 FrontBoardServices 0x00000001175605e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
14 CoreFoundation 0x0000000112e2241c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
15 CoreFoundation 0x0000000112e18165 __CFRunLoopDoBlocks + 341
16 CoreFoundation 0x0000000112e17f25 __CFRunLoopRun + 2389
17 CoreFoundation 0x0000000112e17366 CFRunLoopRunSpecific + 470
18 GraphicsServices 0x00000001138f6a3e GSEventRunModal + 161
19 UIKit 0x0000000111152900 UIApplicationMain + 1282
20 MyAPP 0x000000010f9925b1 main + 97
21 libdyld.dylib 0x0000000113420145 start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
此代码似乎遵循iOS SDK教程,因此我不确定为什么会崩溃。当我更新Spotify.framework时,我删除了旧的(移动到垃圾箱)并删除了派生数据以清除编译器中的缓存。然后我将新的Spotify.framework拖入Xcode。你能看出我是否犯了一些错误吗?请帮忙。