获取错误:从NSUserDefaults对象检索数据时发送到实例0x7fe2b1e71b90的无法识别的选择器
我的代码是:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray *archiveArray = [[NSMutableArray alloc] init];
[_StarredImageUrl addObject:[_photoURLsLargeImage objectAtIndex:gesture.view.tag]];
NSData *personEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:_StarredImageUrl];
[archiveArray addObject:personEncodedObject];
[defaults setObject:archiveArray forKey:@"items"];
[defaults synchronize];
NSLog(@"Starred URL : %@",_StarredImageUrl);
NSLog(@"Starred URL : %@",personEncodedObject);
NSUserDefaults *defaults1 = [NSUserDefaults standardUserDefaults];
NSData *encodedObject = [defaults1 objectForKey:@"items"];
NSLog(@"%@",encodedObject);
_SavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
我正在尝试将photoUrl的数组保存在NSUserDefaults中并从相同的NSUserDefaults加载数据,以验证我是否正确保存了数据。
但是我在最后一行代码中遇到错误,在各种门户网站上搜索过,无法解决,有人可以帮忙。
完全错误:
2016-04-10 01:07:39.797 FlickrP[4450:156655] -[__NSCFArray bytes]: unrecognized selector sent to instance 0x7fe2b1e71b90 2016-04-10 01:07:39.848 FlickrP[4450:156655] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray bytes]: unrecognized selector sent to instance 0x7fe2b1e71b90' *** First throw call stack: ( 0 CoreFoundation 0x000000010fcb6e65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010f3a6deb objc_exception_throw + 48 2 CoreFoundation 0x000000010fcbf48d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010fc0c90a ___forwarding___ + 970 4 CoreFoundation 0x000000010fc0c4b8 _CF_forwarding_prep_0 + 120 5 CoreFoundation 0x000000010fc21dc0 CFStringCreateFromExternalRepresentation + 32 6 Foundation 0x000000010ef953c6 -[NSPlaceholderString initWithData:encoding:] + 115 7 FlickrP 0x000000010ee9eb7b -[ResultstTable Imagetapped:] + 731 8 UIKit 0x000000011054be73 _UIGestureRecognizerSendTargetActions + 153 9 UIKit 0x00000001105484e5 _UIGestureRecognizerSendActions + 162 10 UIKit 0x00000001105464e2 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 843 11 UIKit 0x000000011054e9a0 ___UIGestureRecognizerUpdate_block_invoke904 + 79 12 UIKit 0x000000011054e83e _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 342 13 UIKit 0x000000011053c101 _UIGestureRecognizerUpdate + 2634 14 UIKit 0x00000001100d3f8a -[UIWindow _sendGesturesForEvent:] + 1137 15 UIKit 0x00000001100d51c0 -[UIWindow sendEvent:] + 849 16 UIKit 0x0000000110083b66 -[UIApplication sendEvent:] + 263 17 UIKit 0x000000011005dd97 _UIApplicationHandleEventQueue + 6844 18 CoreFoundation 0x000000010fbe2a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 19 CoreFoundation 0x000000010fbd895c __CFRunLoopDoSources0 + 556 20 CoreFoundation 0x000000010fbd7e13 __CFRunLoopRun + 867 21 CoreFoundation 0x000000010fbd7828 CFRunLoopRunSpecific + 488 22 GraphicsServices 0x0000000113491ad2 GSEventRunModal + 161 23 UIKit 0x0000000110063610 UIApplicationMain + 171 24 FlickrP 0x000000010ee9cebf main + 111 25 libdyld.dylib 0x00000001123f292d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)