我一直试图弄清楚我现在做错了一整天,但我完全不知道为什么应用程序总是会崩溃.
情况如下:
我已经建立了一个简单项目,其中包含所有必需的库和框架.我使用以下实例方法创建了几个Parse用户:
[self signUpUserWithName:@"nico" withPassword:@"123"];
[self signUpUserWithName:@"gabriel" withPassword:@"123"];
[self signUpUserWithName:@"bruno" withPassword:@"123"];
在这里你可以看到方法实现:
-(void)signUpUserWithName:(NSString *)username withPassword:(NSString *)password{
PFUser* user = [PFUser user];
user.password = password;
user.username = username;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if(!error){
NSLog(@"User created.");
}
else{
NSLog(@"User couldn't be created.");
}
}];
}
这按预期工作,用户被创建,一切都很好.现在我正在登录用户并使用以下代码为当前用户创建PFUser对象:
[PFUser logInWithUsername:@"user1" password:@"123"];
//Fetching Current User
PFUser* currentUser = [PFUser currentUser];
if ([currentUser isAuthenticated]){
NSLog(@"Authenticated");
}
else{
NSLog(@"Not Authenticated");
}
这也按预期工作.用户已登录,我收到一个经过身份验证的currentUser对象.现在,我正在尝试使用查询获取用户的对象,如果成功,则将生成的对象分配给currentUser的密钥“myfriends”(创建一对一关系).
PFQuery* friendQuery = [PFUser query];
[friendQuery whereKey:@"username" equalTo:@"user2"];
[friendQuery getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if(!error){
NSLog(@"%@",object);
currentUser[@"myfriends"] = object;
[currentUser save];
}
else{
NSLog(@"Failed getting User Object.");
}
}];
这也按预期工作.如果我现在在Parse中打开我的数据浏览器,我可以看到指向user2对象的指针被分配给“myfriends”.
但如果我重新启动应用程序,则会发生崩溃.如果我将一个PFUser以外的东西(例如带有一些数据的PFObject)分配到另一个PFUser的“myfriends”键,那么一切都运行正常.没有崩溃,完美.但是,如果我正在尝试分配PFUser,它会崩溃并显示以下消息:
2015-01-19 13:44:09.135 localizr[2320:281655] -[__NSCFBoolean _loadSensitiveUserDataFromKeychainItemWithName:]: unrecognized selector sent to instance 0x19967eb60
2015-01-19 13:44:09.136 localizr[2320:281655] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean _loadSensitiveUserDataFromKeychainItemWithName:]: unrecognized selector sent to instance 0x19967eb60'
*** First throw call stack:
(0x188301e48 0x1989fc0e4 0x188308f14 0x188305cc4 0x18820ac1c 0x1000758a4 0x10006f97c 0x10007f25c 0x10007ecbc 0x10007ead4 0x10000d1f8 0x18cb223d0 0x18cd39230 0x18cd3b9b0 0x18cd3a048 0x190565640 0x1882ba124 0x1882b922c 0x1882b742c 0x1881e51f4 0x18cb1b78c 0x18cb16784 0x10000d4c4 0x19906aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我究竟做错了什么?
谢谢你的帮助.
最好的祝愿
尼科
编辑:
这是您要求的堆栈跟踪:
* thread #1: tid = 0xca4e, 0x0000000196d93270 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0000000196d93270 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x0000000196e31228 libsystem_pthread.dylib`pthread_kill + 112
frame #2: 0x0000000196d0ab18 libsystem_c.dylib`abort + 112
frame #3: 0x0000000195df1418 libc++abi.dylib`abort_message + 116
frame #4: 0x0000000195e10b8c libc++abi.dylib`default_terminate_handler() + 304
frame #5: 0x000000019660c3c0 libobjc.A.dylib`_objc_terminate() + 128
frame #6: 0x0000000195e0dbb4 libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x0000000195e0d73c libc++abi.dylib`__cxa_rethrow + 144
frame #8: 0x000000019660c294 libobjc.A.dylib`objc_exception_rethrow + 44
frame #9: 0x0000000185df52a4 CoreFoundation`CFRunLoopRunSpecific + 572
frame #10: 0x000000018a72b78c UIKit`-[UIApplication _run] + 552
frame #11: 0x000000018a726784 UIKit`UIApplicationMain + 1488
* frame #12: 0x00000001001015d4 localizr`main(argc=1, argv=0x000000016fd03a68) + 116 at main.m:14
frame #13: 0x0000000196c7aa08 libdyld.dylib`start + 4
最佳答案 这个问题似乎可以通过Parse iOS / OS X SDK的v1.6.3更新来解决.虽然我遇到了同样的问题,但我还没有更新到新版本,所以我还不能说它是否真的有效……
有关官方讨论和回复,请参阅this link.