• 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: AndrĂ©as Saudemont <email@hidden>
  • Date: Thu, 21 Oct 2004 14:53:38 +0200

Michael,

On Thu, 21 Oct 2004 14:44:53 +0200, Michael Becker <email@hidden> wrote:
> 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?

You should take a look at NSMutableArray's Class Description at:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSMutableArray.html#//apple_ref/doc/uid/20000138-294827

and to retain/release issues in particular.

With your code, the reference count of 'image' reaches zero when its
reference is removed from 'array', so 'image' is deallocated.
That's why the app crashes when you call [image size] afterwards.

Initiliazing 'pointer' to [[array objectAtIndex:0] retain] will solve
your problem (but then do not forget to call [pointer release] at some
later time).

Andréas

--
http://andreassaudemont.net/
_______________________________________________
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

References: 
 >NSMutableArray & Pointers (From: Michael Becker <email@hidden>)

  • Prev by Date: NSMutableArray & Pointers
  • Next by Date: Re: NSMutableArray & Pointers
  • Previous by thread: NSMutableArray & Pointers
  • Next by thread: Re: NSMutableArray & Pointers
  • Index(es):
    • Date
    • Thread