开发者

Is it ok to cast a NSdictionary object to NSMutableDictionary?

开发者 https://www.devze.com 2023-01-15 09:15 出处:网络
Is it ok to cast a NSdictionary object to NSMutableDictionary? NSDictionary *dict; NSMutableDictionary *mDict = (NSMutabl开发者_开发百科eDictionary *)dict;

Is it ok to cast a NSdictionary object to NSMutableDictionary?

NSDictionary *dict;
NSMutableDictionary *mDict = (NSMutabl开发者_开发百科eDictionary *)dict;

Tried this and it worked fine.


No it is not. If you want a mutable dictionary, make one:

NSMutableDictionary* mutableDict = [dict mutableCopy];

Do not forget in accordance with the rules you own mutableDict and must release it when you are done with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消