Frozen objects

I’ve just started to get reports from users running 10.13.2, where some of the API is crapping out because instead of receiving a NSMutableDictionary from [NSDictionary mutableCopy], I’m getting a NSFrozenDictionary that doesn’t respond to KVC. I don’t quite know what to do with it.

From some quick Googling it seems that this is part of Apple’s “CoW” (Copy on Write), but I can’t find any documentation that tells me what I’m supposed to do with these objects.

Anyone got any ptrs they can spare?

Interesting. I’ve had some problems with reading dictionary values from the prefs.

Can you show us your code? What is KVC? At first glance I read this as KFC (the chicken thing).

KVC is Key Value-Coding where you can use dictionary functions on objects, in my case I’m trying to use setObject:forKey or setValue:forKey and both give me a NSException.

I’d love a bit of KFC at the moment, but the nearest one is an hour and half drive away. McDonalds is only two mins away and they have fried chicken, but it ain’t the same.

For NSString and a few other classes Apple internally uses a ton of different classes for implementation.

I bet this is a read only dictionary.

[quote=370988:@Christian Schmitz]For NSString and a few other classes Apple internally uses a ton of different classes for implementation.

I bet this is a read only dictionary.[/quote]
That’s what it seems like, but I am getting it when I am expecting a NSMutableDictionary and I can’t find much information online about it.

I’m trying to figure out what I am meant to do with it, I should have a mutable dictionary instead of this, I just can’t imagine that I’m the only one who’se having this problem.

get a Philip Airfryer and make the SFC (Sam’s Fried Chicken) yourself. All you need is some chicken, spray oil, flour, eggs and 101 herb and spices…

So after hours of tracking this down, I’ve narrowed it to what’s probably an edge case.

The OS gives me a mutable dictionary from the API, however I don’t want to possibly alter anything within the OS, so I make a mutableCopy of the dictionary. On versions prior to 10.13.x, any sub dictionaries within that dictionary are mutable also, however with this new change, the sub dictionaries are now these FrozenDictionaries, so I must go through the root dictionary and also call mutableCopy on each sub dictionary.

The thing is that I know when you get a normal dictionary from API, that it’s not mutable and calling mutableCopy on the dictionary, means you must walk through the contents of the dictionary and mutableCopy any sub dictionaries.

So this change actually brings it in line with what I previously understood about dictionaries, so I don’t know if I should consider it a bug or actually a logical improvement.