• 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: NSMutableArray & Pointers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray & Pointers


  • Subject: Re: NSMutableArray & Pointers
  • From: Michael Becker <email@hidden>
  • Date: Fri, 22 Oct 2004 01:48:31 +0200

Am 21.10.2004 um 14:58 schrieb stephane sudre:
What is happening to the pointer-Variable?? As soon as I try to invoke [ pointer size] in the last line of my code, the app crashes. Is there any way to be able to reasonably perform an "if (pointer==nil)" statement?

AFAIK, it mostly depends on whether [ objectAtIndex:] is returning the object directly or a [[retain] autorelease] pointer. Probably the first one. Anyway, it's up to you to manage retaining/releasing. If you really want to keep track of pointer, you need to retain it before calling removeObjectAtIndex:.

Actually, my general idea was to create a cascading-delete-mechanism. Think of a picture library and a shopping cart. If I move an image to the shopping cart, there will be a "pointer"-Variable in the cart that points to the original image. If I remove the original image from the library (the NSMutableArray), I want the shopping cart to remove that image, too.
So I really do not even want to retain the image, I merely want to check if "pointer" is still pointing to an existing NSImage object.

However, I solved the problem in a (conceptually) different way.

Finally, why pointer should be(come) nil when it's deallocated?

Hm, I think I just assumed it would. I thought a pointer that does not point to any object is a nil-Pointer. However, it seems as though it just keeps on pointing to the same address, giving to you whatever there is...

Anyway, thanks for you replies! Makes me realize that I should take a deeper look at memory management stuff :-)

Kind regards,
Michael

_______________________________________________
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
  • Follow-Ups:
    • Re: NSMutableArray & Pointers
      • From: Scott Stevenson <email@hidden>
    • Re: NSMutableArray & Pointers
      • From: "M. Uli Kusterer" <email@hidden>
References: 
 >NSMutableArray & Pointers (From: Michael Becker <email@hidden>)
 >Re: NSMutableArray & Pointers (From: stephane sudre <email@hidden>)

  • Prev by Date: Fast direct pixel access
  • Next by Date: mixing Cocoa and Carbon
  • Previous by thread: Re: NSMutableArray & Pointers
  • Next by thread: Re: NSMutableArray & Pointers
  • Index(es):
    • Date
    • Thread