Accessing members from NSDictionary
Accessing members from NSDictionary
- Subject: Accessing members from NSDictionary
- From: Pax <email@hidden>
- Date: Fri, 05 Apr 2013 13:38:53 +0100
I have a situation where a user might have a great many information windows open at the same time (like the situation in Finder where you can click on a file and select 'Get Info' ad infinitum.)
In order handle this situation, and so that I can still update each Window individually, I decided to store the information window classes in an NSDictionary so that I can fiddle with them individually (and release them individually, obviously).
This seems to work quite well - except that I can't seem to access public member variables. The following code gives the error 'No member named 'infoWindow' in 'struct objc_object'
NSEnumerator *e = [connectedDevices objectEnumerator];
id device;
while (device = [e nextObject])
{
if ([[device objectForKey:@"LocationID"] isEqualToNumber:[sender representedObject]])
{
[device setObject:[[DisplayInformation alloc] initWithDictionary:device] forKey:@"InformationWindowRef"];
[[device objectForKey:@"InformationWindowRef"] showWindow:self];
Error Here --->[[device objectForKey:@"InformationWindowRef"]->infoWindow cascadeTopLeftFromPoint:NSMakePoint(20,20)];
}
}
So I have a few questions:
1. Am I approaching this problem correctly? After all, just because something (mostly) works, it doesn't mean that it is the right, or efficient, way to do things.
2. If my plan isn't utter lunacy, how do I get to the member variable?
3. If my plan is lunacy, or if there's a better more efficient solution, what is it?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden