NSMutableDictionary and new items insertion KVO?

From the Key-Value Coding methods document, only NSMutableArray or NSMutableSet is supported for To-Many properties. Since, KVC already works with keys, it would be redundant to have NSMutableDictionary supported since it's effectively what setValue:forKey: already does.

From the Key-Value Coding methods document, only NSMutableArray or NSMutableSet is supported for To-Many properties. Since, KVC already works with keys, it would be redundant to have NSMutableDictionary supported since it's effectively what setValue:forKey: already does. Maybe override setValue:forKeyPath: if you really want this in one call.

Hard to say if it would be redundant. In my case I wouldn't say that it would be redundant, dictionary here is just a data structure. I could use let's say NSMutableArray and store in it key and value within a new Data class.

From the KVO point of view it wouldn't be redundant, but for me it would decrease performance since for every update of value it would require to iterate whole collection... – Krokodylowy Nov 18 '11 at 9:51 1 I think you're over-thinking this. You have an object holding a Dictionary and you're try to both access it, and specify a value for a key in a single call. It would be much easier to just split this in two KVC calls : one to get the Dictionary (like you would any property) , and then setValue:forKey: on the dictionary.

Otherwise, maybe override setValue:forKeyPath: of the controller. – Qwerty Bob Nov 18 '11 at 13:31 Today I've studied Key-Value Coding Programming Guide carefully and you are right only NSMutableArray and NSMutableSet support to-many properties. Now I'm going to design a class containing a dictionary but have all accessor methods to be compilant with KVO and behave like NSMutableArray.Thanks.

– Krokodylowy Nov 19 '11 at 12:56.

You need to call something like _tableView reloadData; That will tell your tableview to essentially refresh everything it knows.

I know that it's possible, but in my real application it would break MVC pattern - I don't want to have an outlet in my DataManager class. Some way to go would be using block which would call realoadData: method but I feel that KVO it designed to deal with problems like mine. – Krokodylowy Nov 17 '11 at 15:20 @Krokodylowy : AppController must be a controller class (otherwise you are already breaking the pattern).

It doesn't break MVC to send -reloadData in -addRandomPair: – JeremyP Nov 17 '11 at 15:37 @JeremyP the source coude posted in the question is only a proof of concept application. Real application has a Model where is a DataManager, model is handled by ModelController (facade design pattern), AppController has an ivar of the ModellController and there are also several windows (for each there is a custom NSWindowController class) so I would really like to use KVO instead of calling reloadData:. – Krokodylowy Nov 17 '11 at 16:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions