Re: Two arrays sharing the same adress space.
Re: Two arrays sharing the same adress space.
- Subject: Re: Two arrays sharing the same adress space.
- From: "Stephen J. Butler" <email@hidden>
- Date: Mon, 17 Nov 2008 00:03:08 -0600
On Sun, Nov 16, 2008 at 11:52 PM, Sandro Noel <email@hidden> wrote:
> as it turns out. with the bug fixed the mounts array is left null because
> the file does not exist yet.
> so further in the program is i try to add to the array, nothing happens.
>
> and if i try "mounts = [[NSMutableArray alloc] init];" only the two arrays
> get the same pointer.
Well, then what's happening is obvious. initWithContentsOfFile: fails
because the file doesn't exist, so it performs cleanup (aka, call
release) and returns null. Your next alloc then just happens to grab
the same memory block. So two things to learn from this:
1) never call the init* methods twice on the same object.
2) always use the value returned from an init* method.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden