Visitar URL original
Crash on iPad 9.3 on importDictionary · Issue #627 · jsonmodel/jsonmodel · GitHub
Skip to content

Crash on iPad 9.3 on importDictionary #627

Open

Description

@pabrr

I'm using JSONModel 1.8.0 and on iPad 9.3.5 there is crash on line 180:
if (![self __importDictionary:dict withKeyMapper:self.__keyMapper validation:YES error:err])

Logs show nothing but:
Uncaught exception: -[__NSCFConstantString charValue]: unrecognized selector sent to instance 0x35f67888

For some reason dict value is nil and crash does not repeat on other devices I tested: iPad Air or any iPhones.

Have no data to show that. Is there any way you could help me?

Activity

  1. billinghamj commented on Nov 9, 2018

    @billinghamj
    Member

    Please feel free to open a PR. I am not able to help otherwise unfortunately.

  2. pabrr commented on Nov 13, 2018

    @pabrr
    Author

    The crash seems to happen only if the framework is used via Carthage.
    With CocoaPods works fine

  3. AbnerChen028 commented on Feb 26, 2019

    @AbnerChen028

    It's different between 32CPU and 64CPU

    If your json is :

    {
    "a": "1",
    "b": "1"
    }

    but you model is:

    @property (nonatomic, assign) BOOL a;
    @property (nonatomic, assign) NSInteger b;

    Will be crash in 32CPU:

    -[__NSCFString charValue]: unrecognized selector sent to instance 0xxxxx
    -[__NSCFString longValue]: unrecognized selector sent to instance 0xxxxx
    

    How to fix:

    1. Change service json format to:
    {
    "a": 1,
    "b": 1
    }
    1. Add a category for NSString:
    @interface NSString (JSONModel)
    
    #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
    #else
    @property (nonatomic, assign, readonly) NSInteger longValue;
    @property (nonatomic, assign, readonly) BOOL charValue;
    #endif
    
    @end
    @implementation NSString (JSONModel)
    
    #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
    #else
    - (NSInteger)longValue {
        return [self integerValue];
    }
    
    - (BOOL)charValue {
        return [self boolValue];
    }
    #endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions