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

/ vanishing info in a global variable /


  • Subject: / vanishing info in a global variable /
  • From: Luis E! <email@hidden>
  • Date: Wed, 30 Jun 2004 15:07:47 +0100 (BST)

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:

theCharacterList = [[CharacterList alloc] init];

Later on, I load a file with my application and
extract some information that I put in two mutable
arrays: theCharacters and theDialogsPerCharacter. I
want to keep, this info so I store it in my class. I
do the following:

[theCharacterList setCharactersArray: theCharacters];
[theCharacterList setDialogsPerCharacter:
theDialogsPerCharacter];

setCharactersArray and setDialogsPerCharacter are
defined in the CharacterList class, of course. I test
it to see if everything's ok, so I display a value of
theCharacters:

[bDisplay setStringValue: [[theCharacterList
getCharactersArray] objectAtIndex: 0]];

Value's displayed. Everything's fine so far. The
method ends and everything feels good. However, I try
to access to theCharacterList variable in other method
and my program goes BOOM! Program received signal:
"EXC_BAD_ACCESS".

It finds a null pointer when it's trying to access
theCharacters... so, where is all my information? The
info that was supposed to be there? It's not being
stored! When the method that reads the data and does
the setCharactersArray and setDialogsPerCharacter
ends, the variable empties again!

Boy, I'm starting to lose all hope here... :(





___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com
_______________________________________________
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.


  • Follow-Ups:
    • Re: vanishing info in a global variable
      • From: "Louis C. Sacha" <email@hidden>
  • Prev by Date: Re: Strategy to split up large class files?
  • Next by Date: Re: Strategy to split up large class files?
  • Previous by thread: Re: Add application to Startup Items?
  • Next by thread: Re: vanishing info in a global variable
  • Index(es):
    • Date
    • Thread