// populate 'project' with contents of key in `gDictRoot`
NSDictionary *project = [gDictRoot valueForKeyPath:@"root.project0"];
// modify 'project' as necessary - actual code omitted for brevity
[project setValue:[someDict valueForKey:@"foo"] forKeyPath:@"parameters.foo"];
// add 'project' to 'gDictRoot' so it isn't lost when the view is dismissed
[gDictRoot setValue:project forKeyPath:@"root.project2"];
三線,在這裏我想補充project
到gDictRoot
- project0
也被修改。不知道爲什麼。的NSMutableDictionary setValue方法:forKeyPath:設置多個鍵
什麼'的NSLog(@ 「%P%P」,[gDictRoot valueForKeyPath:@「root.project0 「],[gDictRoot valueForKeyPath:@」root.project2「]);'給你嗎? – 2012-08-13 15:12:41
'0x6b9cc10 0x6b9cc10' ...我接受它我不正確地初始化'項目'? – Thromordyn 2012-08-13 15:14:58
您正在將它初始化爲指向根詞典中位於'@「root.project0」'處的同一事物的指針。也許你想要一個副本? – 2012-08-13 15:16:28