English 中文(简体)
为什么我的国家安全局 Dictionary正在被搁置?
原标题:Why my NSMutableDictionary is getting null in setObject?

我正在尝试这一法典。

 NSString *titleOfPlace = [place objectForKey:@"name"];
 NSString *reference = [place objectForKey:@"reference"];
 [placesExtraInfo setObject:reference forKey:titleOfPlace];
 NSLog(@"%@", (NSString *)[placesExtraInfo objectForKey:titleOfPlace]);

产出:

2011-11-21 10:06:49.536 Tittle-Tattle[25545:1bb03] 0
2011-11-21 10:06:49.554 Tittle-Tattle[25545:1bb03] (null)
2011-11-21 10:06:49.555 Tittle-Tattle[25545:1bb03] (null)
2011-11-21 10:06:49.555 Tittle-Tattle[25545:1bb03] (null)
2011-11-21 10:06:49.555 Tittle-Tattle[25545:1bb03] (null)
.... about 20 of them as I had 20 objects to add...

What am I doing wrong?

<<>PS>/strong> 缩略语 为什么没有在安全局档案库内加以保存?

感谢提供的任何投入。

<>>>>>

title John s Grill
reference CnRkAAAAmyHKGYtr9brX5uJEwlyK791oCWErzrY8hKjFX2eXBV5hrrbVjE_-CPvCfoxUpu4TiXswTXUtvP_UkYG2p4RG2a1oc_4HSxku1jIlVx0H4LZgo_SQbUMSrJ1xDvwxxWVsyWtEjxCIF6qma_slsFSLphIQmSnwBgYQATX46MXkuW0s5BoUGM0K_KRvH_gbc4k-TSsSpgnQyTk
please no null (null)
2011-11-21 10:19:40.339 Tittle-Tattle[30277:1bb03] title Fifth Floor
reference CnRiAAAAtzTFHqqcAMyYzuKSq7nwHdt9e-lnP1W4i6pyUGQiomT0SvqDm1RWxhH05fJpqMJ9RdU8QHO-g7-EXgVHQnoms_bip5gGXdE96SCN7HQW5-Y69K7144VvgnOATVVNZRWQgyNZ2NNYRSltVuL61UXg7BIQ8YinfdZ6Ahq2lU6XhNVQ7hoU2IwUAHKcGHELPeYgbshPmiS9nOA
please no null (null)
2011-11-21 10:19:40.339 Tittle-Tattle[30277:1bb03] title Ghirardelli Chocolate
reference CnRsAAAAkHnx_nYhhe4QnV2jQyWdU5Vb387rFdVlhPcsnp6ZUjEroEzRLCcYO687ybSlTqSMDP5BxJVeehgUt9kkL97l1puos89e2HT85t-H5VWl7G0qZ0M_IoL0Gp3VmKl07MQRFt0_zdXesSVjSzLFRpBDChIQwcpeapYjGYq8jSQTZUmoMxoUSS1M0rBvMkqKSRRGMpWlyWbHUJ0
please no null (null)
最佳回答

如我在以上评论中所说,确保<代码> > > 域外信息/编码><><> > > > > <> > > (如果你寄送<代码>objectForKey:至nil,将退回nil。)

问题回答

我认为,albertamg是正确的——支票编码——ExtraInfo。 你的问题只是说,你先核对了<条码>,标题OfPlace和<条码>。 储存<代码>nil 输入字典将产生一种例外,但将任何东西传送到<代码>nil的结果载于nil

albertamg正在做一些事情。

您不能确定无危险价值,也不能将非危险价值设定为无危险钥匙。

//given
NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
//will crash here
[dict setObject:nil forKey:@"key"];
//will crash here if the above line is commented out
[dict setObject:@"val" forKey:nil];

However,

 NSLog(@"%@", [nil objectForKey:@"key"]);

产出

2011-11-20 18:22:08.609 TestEnvironment[1221:207] (null)




相关问题
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, ...

热门标签