由于未捕获的异常'RLMException'而终止应用程序,原因:'int'领域的'NSTaggedPointerString'类型的'无效值'1973906'

如果我将属性定义为String。

@Property NSString * value;
  

由于未捕获的异常“ RLMException”而终止应用程序,原因:   “字符串”为'__NSCFNumber'类型的'无效值'1993654'

或者定义为整数。

@Property NSInteger value;
  

由于未捕获的异常“ RLMException”而终止应用程序,原因:   'int'的'NSTaggedPointerString'类型的'无效值'1973906'

在这两种情况下,应用都崩溃了。

崩溃报告。

*** Terminating app due to uncaught exception 'RLMException',reason: 'Invalid value '1973906' of type 'NSTaggedPointerString' for 'int?' property 'MMCase.Id'.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
    2   Realm                               0x000000010ad75659 _Z17RLMThrowTypeErrorP11objc_objectP15RLMObjectSchemaP11RLMProperty + 617
    3   Realm                               0x000000010ad766bb _Z27RLMValidateValueForPropertyP11objc_objectP15RLMObjectSchemaP11RLMPropertyb + 3659
    4   Realm                               0x000000010ab63576 _ZN18RLMaccessorContext18value_for_propertyEP11objc_objectRKN5realm8PropertyEm + 214
    5   Realm                               0x000000010abd70af _ZN5realm6Object6createIU8__strongP11objc_object18RLMaccessorContextEES0_RT0_RKNSt3__110shared_ptrINS_5RealmEEERKNS_12ObjectSchemaET_bbmPNS_8BasicRowINS_5TableEEE + 431
    6   Realm                               0x000000010abd8595 RLMCreateObjectInRealmWithValue + 1477
    7   Realm                               0x000000010ab62c18 _ZN18RLMaccessorContext5unboxIN5realm12BasicRowExprINS1_5TableEEEEET_P11objc_objectbbbm + 296
    8   Realm                               0x000000010ab745cd _ZN5realm12_GLOBAL__N_112ValueUpdaterIU8__strongP11objc_object18RLMaccessorContexteclEPNS_12BasicRowExprINS_5TableEEE + 157
    9   Realm                               0x000000010ab735ef
red2yuri 回答:由于未捕获的异常'RLMException'而终止应用程序,原因:'int'领域的'NSTaggedPointerString'类型的'无效值'1973906'

您应该尝试使用NSNumber *value;。您发布的第一个例外__NSCFNumber中指出了这一点。从那里您可以使用

[value stringValue];

[value intValue];

要创建它,可以使用范例:

value = [NSNumber numberWithInt: intValue];
,

使用NSNumber代替NSIntger进行了修复。

使用

@property NSNumber<RLMInt> *value

代替

@Property NSInteger value;

取决于类型。

本文链接:https://www.f2er.com/3161065.html

大家都在问