Re: Array Problems
Re: Array Problems
- Subject: Re: Array Problems
- From: Serge Meynard <email@hidden>
- Date: Sun, 10 Apr 2005 18:00:31 -0400
On Apr 10, 2005, at 16:56, David Rocamora wrote:
Sorry for being unclear. I am convinced that my trouble is in
MyDocuments init method. Here is init from MyDocument's
implementation:
- (id)init
{
if (self = [super init]) {
artworks = [[NSMutableArray alloc] init];
activeSet = artworks;
[self createNewArtwork];
..snip...
[self updateUI];
}
return self;
}
I believe this is the problem because it is run two times. Once when
the program is started and then right after makeWindowControllers is
run. This creates two artworks arrays at different addresses.
[snip]
Is there a better place to put the code that initializes the array?
Thanks,
Dave
I see no obvious reason why init would get called twice, and why two
different document objects would seem to be used at the same time.
However... Just taking a guess here, but it's been my experience that
if something you do inside your init goes bad (probably raising an
uncaught exception), you can mess up your objects and cause weird
things to happen. I've done it to myself a few times by simply
forgetting the "return self" at the end (not a good idea). Also note
that the app's behavior might change depending on if you're running
with or without the debugger (which is always great fun).
I'm assuming that [self updateUI] does stuff with the outlets in your
main window. This won't work, since the outlets have not been connected
yet; you should move that call to the windowControllerDidLoadNib:
method. That might fix it...
Anyway, I suggest you at least put a breakpoint in your init method and
try to figure out why it's being called twice (and from where).
Serge
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden