• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing members from NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing members from NSDictionary


  • Subject: Re: Accessing members from NSDictionary
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 05 Apr 2013 14:20:46 +0100

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@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

  • Follow-Ups:
    • Re: Accessing members from NSDictionary
      • From: Pax <email@hidden>
References: 
 >Accessing members from NSDictionary (From: Pax <email@hidden>)

  • Prev by Date: Accessing members from NSDictionary
  • Next by Date: Re: Accessing members from NSDictionary
  • Previous by thread: Accessing members from NSDictionary
  • Next by thread: Re: Accessing members from NSDictionary
  • Index(es):
    • Date
    • Thread