Setnilvalueforkey:could not set nil as the value for the key distance. Solution

Source: Internet
Author: User

In a small project, this error occurs when the JSON data is parsed and assigned to a dictionary or array.
The main reason is that the value of the value of the assignment is nil, while the Nsdictionary and Nsarray storage objects cannot be nil, only the OC object.

0x7fb2a8558c50notsetastheforthe key distance.‘

Here is the value assigned to the distance variable is nil
Then you can override the method

- (void)setNilValueForKey:(NSString *)key;
- (void)setNilValueForKey:(NSString *)key {    if ([key isEqualToString:@"distance"]) {        0;    }else {        [super setNilValueForKey:key];    }}

As for the value of distance, combine the project to take reasonable value processing.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Setnilvalueforkey:could not set nil as the value for the key distance. Solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.