Why does NSDictionary freak out when we have @ symbol in its keys?

<>

This question already has an answer here:

Answers


You can't use @ in the keys in conjunction with valueForKey:. NSDictionary has some documented but perhaps unexpected behavior in that case: it strips the @ and invokes [super valueForKey:] with the new key. That looks for the key on the object, not in the dictionary's contents. No such key exists on instances of NSDictionary, so an exception is raised.

You should in general use objectForKey: to retrieve values from an NSDictionary.

Credit must go to Ken Thomases for his comments below, correcting earlier versions of this answer.


Need Your Help

Save data to memory and after some time save them to DB

nosql redis cassandra key-value

please accept my apologies in advance because this is probably a stupid question. But...

C struct, union pointer to struct

c pointers casting struct unions

I have a typedeffed struct and an union. The union contains the struct and a single uint32_t. The goal is to assign a value to foo that corresponds to the 'bits' in the struct.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.