On Tue, Apr 22, 2008 at 2:45 PM, Peter Browne
<[EMAIL PROTECTED]> wrote:

>  I'm getting an "EXC_BAD_ACCESS" error.
>
>  I've since managed to solve the problem by inserting a
>
>  [myArray retain];
>
>  but I'm not entirely sure WHY this fixed it...
>
>  The process followed is:
>
>  1) the myController object acquires data from a text file, using NSString's
> -stringWithContentsOfFile:encoding:error
>  2) myArray then grabs this data (a bunch of numbers) using NSArray's
> -componentsSeparatedByString:
>  3) myController then passes the myArray object to myView (for later graph
> drawing) using my - (void)displayData:(NSArray *)theArray method
>  4) myView then calls [theArray count]
>  5) EXC_BAD_ACCESS
>
>  inserting a [myArray retain] just before passing the data to the view fixed
> the problem. Why should this be the case?
>  As far as I'm aware the object isn't being released at that point, so
> what's the need for a -retain message?

Read the following carefully (in particular for the issue biting you
look for any discussion on "convenience" methods/constructors and the
use of proper accessors)...

<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/index.html>

-Shawn
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to