• 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: vanishing info in a global variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vanishing info in a global variable


  • Subject: Re: vanishing info in a global variable
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Wed, 30 Jun 2004 18:28:24 -0700

Hello...

What you probably want to do instead is declare the variable in the header file as

extern CharacterList *theCharacterList;

then, in the corresponding .m file, you would declare one instance of the variable that is accessed using the external declaration

CharacterList *theCharacterList = nil;


Also, it would probably be better to create the instance that the variable points to in a different method that will only be called once per run of the application (depending on how your application loads nib files, awakeFromNib can potentially be called multiple times).

If you are creating the global instance of the variable in your application delegate, the best method to do this would probably be the applicationWillFinishLaunching: method.


Hope that helps,

Louis

I want a global variable of a type created by me. So I
declared it in the .h file as follows:

CharacterList *theCharacterList;

Then, in the .m file, I initialize it in the
awakeFromNib: method as follows:
...
_______________________________________________
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: 
 >/ vanishing info in a global variable / (From: Luis E! <email@hidden>)

  • Prev by Date: Consistent naming interfaces across all the Apple's Framework
  • Next by Date: Re: Setting NSPopUpButtonCell Value from NSTable
  • Previous by thread: / vanishing info in a global variable /
  • Next by thread: More... apparently not-so-simple printing issues
  • Index(es):
    • Date
    • Thread