English 中文(简体)
从列表文件读取字典时的奇怪行为字典
原标题:Strange behavior reading Dictionary from a plist file

When I read a plist for a dictionary which is not empty and has at-least one key value pair into an NSMutableDictionary property of my model class, Everything works fine. I can add,delete modify the mutable dictionary.

但当字典 < 坚固> 是空

并用这样的标签可以看到此列表 :

然后,尽管我的财产有一个NSM变数指示器, 所创造的物体变得不可改变。

and when I try to set an object in it for a particular property, It gives me this error saying:

NS 内部一致性例外,原因: - -- NSCF 变量设置Object:forKey: :: 向不可变对象发送突变方法

最佳回答
NSMutableDictionary *mutable = [yourApparentlyMutableDictionary mutableCopy];
问题回答

相当肯定从列表中检索到的所有物体都是不可变异的变异物。 但是,我确实看到了一种选择,可以把它们消散成变异。

编辑 :

本篇文章解释如何将一个可变列表划为可变列表:

http://cocoadev.com/wiki/PropertyList





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签