struct myStruct {
NSUInteger value;
NSString *s;
} myItem[2] = {
{ 1, @"test"},
{ 2, @"test2"}
};
NSDictionary *myDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSValue valueWithPointer:&myItem[0]], @"myKey1",
[NSValue valueWithPointer:&myItem[1]], @"myKey2",
nil];
Showing posts with label struct. Show all posts
Showing posts with label struct. Show all posts
Tuesday, February 2, 2010
How to Use Struct in NSDictionary
Thought I wanted to use a NSDictionary for some reason, but after all the trouble didn't. However it was quite a challenge to make it work, so I'll post here a code sample. Maybe it will be useful at some other time:
Subscribe to:
Posts (Atom)