You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rajsesh
changed the title
Wrong behaviour on set nil/NULL for key into NSMutableDictionary
Mutable collections in foundation must not allow nil objects to be inserted
Jan 7, 2017
Note, this is also an issue in NSCFArray addObject, insertObject, (possibly also equivalent methods in NSCFAttributedString). Our assumption is that CF will handle null values. The api contract is that foundation APIs have to throw in these circumstances. Could we fix all these instances in one shot (see also #1435)
Now trying to insert into NSArray, NSDictionary, NSSet, and NSAttributedString will throw an NSException.
Fixes#1607
* Prevent insertion of nil into foundation collections
* Address CR feedback, throw for sets as well
* Missed one
I think it's critical issue.
Example of code:
On iOS dictionary has only key1 and key4, print in debug:
logged on WinObjC:
But need to remember that on iOS version of Foundation, next line cause exception:
[dictionary setObject:nil forKey:@"key5"];
Exception log:
But on WinObjC, it will let you insert nil object.
The text was updated successfully, but these errors were encountered: