On 5 Apr 2013, at 13:38, Pax wrote:
> 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?
For a start, trying to access instance variables directly is almost always a
bad idea. Expose proper accessor methods instead.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]