• 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: [Newbie] Good NSDictionary example?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Newbie] Good NSDictionary example?


  • Subject: Re: [Newbie] Good NSDictionary example?
  • From: Andreas Mayer <email@hidden>
  • Date: Sun, 8 Sep 2002 14:08:38 +0200

Am Sonntag, 08.09.02 um 06:11 Uhr schrieb Keith Pritchard:

id myDict=[NSMutableDictionary dictionaryWithObjectsAndKeys:

Unless there's a good reason not to, use a qualified type:

NSMutableDictionary *myDict = [...

That will help the compiler to detect errors in your code.

I tried [myDict retain] but ok, I suppose that was a bit optimistic :-)

That's fine.

But it seems, your myDict variable got out of scope.
So the object is still there, but you have no way to access ist.

How can I make it accessible to the whole controller?

You will have to declare it as a property of the controller class.

Next you'll probably want to write setter and getter methods:

- (void)setMyDict:(NSMutableDictionary *)newMyDict
{
NSMutableDictionary *oldValue = myDict;
myDict = [newMyDict retain];
[oldValue release];
}

- (NSMutableDictionary *)myDict
{
return myDict;
}

Put these methods in your public interface to access myDict from outside your controller.

And don't forget to release it when the controller is destroyed:

- (void)dealloc
{
[myDict release];
... more ...
[super dealloc];
}


bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: [Newbie] Good NSDictionary example? (From: Keith Pritchard <email@hidden>)

  • Prev by Date: Re: Objects between threads
  • Next by Date: Re: Drawer size reverts to window size automatically. Why?
  • Previous by thread: Re: [Newbie] Good NSDictionary example?
  • Next by thread: Two-level namespaces?
  • Index(es):
    • Date
    • Thread