Re: NSMutableArray & Pointers
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