• 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
Re: Two arrays sharing the same adress space.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Two arrays sharing the same adress space.
      • From: Andy Lee <email@hidden>
    • Re: Two arrays sharing the same adress space.
      • From: "Kyle Sluder" <email@hidden>
References: 
 >Re: Two arrays sharing the same adress space. (From: Scott Ribe <email@hidden>)
 >Re: Two arrays sharing the same adress space. (From: Sandro Noel <email@hidden>)
 >Re: Two arrays sharing the same adress space. (From: Charles Steinman <email@hidden>)
 >Re: Two arrays sharing the same adress space. (From: Sandro Noel <email@hidden>)

  • Prev by Date: Re: Two arrays sharing the same adress space.
  • Next by Date: Re: Two arrays sharing the same adress space.
  • Previous by thread: Re: Two arrays sharing the same adress space.
  • Next by thread: Re: Two arrays sharing the same adress space.
  • Index(es):
    • Date
    • Thread