我的应用程序使用FMDB和Mantle,在iPhone 5模拟器之后一切正常但在iPhone 5s之前崩溃,看起来像Bool Variable是原因.但我无法理解为什么iPhone 5s,6和6 plus上的一切正常. @property (nonatomic, assign) BOOL
@property (nonatomic, assign) BOOL isMyFan;
@property (nonatomic, assign) BOOL isMyFollow;
@property (nonatomic, assign) NSInteger cityID;
@property (nonatomic, assign) NSInteger provinceID;
@property (nonatomic, assign) NSInteger locationID;
2015-07-14 21:33:17.264 ATOMPSGod[48894:607] -[__NSCFString charValue]: unrecognized selector sent to instance 0x79fb7700
2015-07-14 21:33:17.268 ATOMPSGod[48894:607] *** Caught exception setting key "isMyFollow" : -[__NSCFString charValue]: unrecognized selector sent to instance 0x79fb7700
2015-07-14 21:33:17.277 ATOMPSGod[48894:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString charValue]: unrecognized selector sent to instance 0x79fb7700'
*** First throw call stack:
(
0 CoreFoundation 0x026201e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x022ba8e5 objc_exception_throw + 44
2 CoreFoundation 0x026bd243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0261050b ___forwarding___ + 1019
4 CoreFoundation 0x026100ee _CF_forwarding_prep_0 + 14
5 Foundation 0x01f3eb39 _NSSetCharValueForKeyWithMethod + 67
6 Foundation 0x01ee727f _NSSetUsingKeyValueSetter + 256
7 Foundation 0x01ee6731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
8 ATOMPSGod 0x0020f1a7 MTLValidateAndSetValue + 311
9 ATOMPSGod 0x0020ef19 -[MTLModel initWithDictionary:error:] + 697
10 ATOMPSGod 0x0020eb9e +[MTLModel modelWithDictionary:error:] + 126
11 ATOMPSGod 0x000e3d54 -[MTLFMDBAdapter initWithFMResultSet:modelClass:error:] + 6836
12 ATOMPSGod 0x000e20fb +[MTLFMDBAdapter modelOfClass:fromFMResultSet:error:] + 139
13 ATOMPSGod 0x00139746 __25+[ATOMUserDAO fetchUser:]_block_invoke + 246
14 ATOMPSGod 0x00299cec __30-[FMDatabaseQueue inDatabase:]_block_invoke + 108
15 libdispatch.dylib 0x03c124d0 _dispatch_client_callout + 14
16 libdispatch.dylib 0x03bff740 _dispatch_barrier_sync_f_invoke + 58
17 libdispatch.dylib 0x03bff3ea dispatch_barrier_sync_f + 89
18 libdispatch.dylib 0x03bff90b dispatch_sync + 37
19 ATOMPSGod 0x00299c15 -[FMDatabaseQueue inDatabase:] + 341
20 ATOMPSGod 0x0013954e +[ATOMUserDAO fetchUser:] + 286
21 ATOMPSGod 0x00133c9e -[ATOMCurrentUser fetchCurrentUserInDB:] + 190
22 ATOMPSGod 0x0002e9f7 -[AppDelegate application:didFinishLaunchingWithOptions:] + 663
23 UIKit 0x02c3314f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
24 UIKit 0x02c33aa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
25 UIKit 0x02c38667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
26 UIKit 0x02c4cf92 -[UIApplication handleEvent:withNewEvent:] + 3517
27 UIKit 0x02c4d555 -[UIApplication sendEvent:] + 85
28 UIKit 0x02c3a250 _UIApplicationHandleEvent + 683
29 GraphicsServices 0x050cff02 _PurpleEventCallback + 776
30 GraphicsServices 0x050cfa0d PurpleEventCallback + 46
31 CoreFoundation 0x0259bca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
32 CoreFoundation 0x0259b9db __CFRunLoopDoSource1 + 523
33 CoreFoundation 0x025c668c __CFRunLoopRun + 2156
34 CoreFoundation 0x025c59d3 CFRunLoopRunSpecific + 467
35 CoreFoundation 0x025c57eb CFRunLoopRunInMode + 123
36 UIKit 0x02c37d9c -[UIApplication _run] + 840
37 UIKit 0x02c39f9b UIApplicationMain + 1225
38 ATOMPSGod 0x00112cba main + 138
39 libdyld.dylib 0x03e466d9 start + 1
)
libc abi.dylib:以NSException类型的未捕获异常终止
(LLDB)
使用变量视图更新:
key __NSCFString * @"isMyFollow" 0x79e50400 obj ATOMUser * 0x79e46e30 0x79e46e30 ATOMBaseModel ATOMBaseModel _boundWeibo BOOL NO '\0' _boundWechat BOOL NO '\0' _isMyFan BOOL NO '\0' _isMyFollow BOOL NO '\0' _uid int 0 0 _cityID NSInteger 0 0 _provinceID NSInteger 0 0 _locationID NSInteger 0 0 _mobile NSString * nil 0x00000000 _nickname NSString * nil 0x00000000 _avatar NSString * nil 0x00000000 _backgroundImage NSString * nil 0x00000000 _sex NSInteger 0 0 _attentionNumber NSInteger 11 11 _fansNumber NSInteger 0 0 _praiseNumber NSInteger 0 0 _uploadNumber NSInteger 0 0 _replyNumber NSInteger 0 0 _proceedingNumber NSInteger 0 0 _attentionUploadNumber NSInteger 0 0 _attentionWorkNumber NSInteger 0 0 forceUpdate BOOL YES '\x01' value __NSCFString * @"0" 0x79e3e140 error NSError ** NULL 0x00000000 validatedValue __NSCFString * @"0" 0x79e3e140原始答案:如果它适用于iPhone 5S及更高版本,它似乎是32/64位问题,因为自5S以来所有iPhone都是64位.更确切地说,对于32位系统,BOOL是一个有符号的字符,而在64位下它是一个bool.
您可以在此here上阅读更多内容.
更新:我认为您的问题有待处理在集合中存储BOOL值.存储在obj-c集合中的BOOL值包装在NSNumber对象中,因为集合只能保存对象.你应该像这样使用它:
NSDictionary *dict = @{@"BOOL_Key": [NSNumber numberWithBool:YES]};
BOOL myBool = [[dict objectForKey:@"BOOL_Key"] boolValue];
或者您可以使用@(YES)代替[NSNumber numberWithBool:].如果您不使用boolValue,您可能会得到不可预测的结果.希望能帮助到你.
