0
votes

if I define property as String.

@Property NSString * value;

Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '1993654' of type '__NSCFNumber' for 'string?'

Or if define as integer.

@Property NSInteger value;

Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '1973906' of type 'NSTaggedPointerString' for 'int'

in both cases app crashed.

Crash Report.

*** 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
2
It seems that you have mixed Int & String. And some values are then invalid for one case or the other. - Larme
Can you please include the code that's crashing and indicate which specific line is causing the crash? As it is, you could be trying to store invalid or nil data into your var which would cause a crash. Please take a moment and review How to create a Minimal, Complete, and Verifiable example - Jay

2 Answers

1
votes

You should try with NSNumber *value; instead. This is pointed out in the first exception you posted __NSCFNumber. From there you can use either

[value stringValue];

or

[value intValue];

To create it, you can use paradigm:

value = [NSNumber numberWithInt: intValue];
0
votes

fixed by using NSNumber instead of NSIntger.

use

@property NSNumber<RLMInt> *value

instead of

@Property NSInteger value;

Depends on type.