Re: basic Obj-C lesson (was runtime error with NSArray no
Re: basic Obj-C lesson (was runtime error with NSArray no
- Subject: Re: basic Obj-C lesson (was runtime error with NSArray no
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 9 Dec 2002 10:45:00 -0500
There isn't anything in your - (IBAction)swap:(id)sender method that
could directly change the retain counts of the contained objects. So,
it must be something indirect -- something called by the method.
In particular, this...
[self setStat:stat1 atIndex:stat2i];
[self setStat:stat2 atIndex:stat1i];
... appears to be the only two lines that might do anything that affect
retain counts. I'm assuming that -setStat:atIndex: manipulates the
contents of an array-- removing the old, inserting the new. When it
does this, the old will be released. While that behavior may be
correct inside of -setStat:atIndex:, it causes the calling method to
explode.
I would suggest doing something like the following.
[stat1 retain];
[stat2 retain];
[self setStat:stat1 atIndex:stat2i];
[self setStat:stat2 atIndex:stat1i];
[stat1 release];
[stat2 release];
b.bum
_______________________________________________
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.