开发者

Is it ok to cast a NSdictionary object to NSMutableDictionary?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜