Re: vanishing info in a global variable
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.