Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does this keep sending EXC_BAD_ACCESS



At 12:14 Uhr -0700 30.03.2004, April Gendill wrote:
Make sure that if the array is global it is declared some where in the header or above the implementation line in the class file.
NSMutableArray * serverWindows;

Just a suggestion: Do

NSMutableArray* serverWindows = nil;

then in your init method:

serverWindows = [[NSMutableArray alloc]init];

Wrap the actual code that alloc/inits the array in an

if( serverWindows == nil )
{
...
}

That way, when your code is called multiple times, it will just use the same global array (which is probably the point of using a global array anyway). Or if it isn't in your case, feel free to add an

if( serverWindows != nil )
{
[serverWindows release];
serverWindows = nil;
}

before the array creation step (you could then leave the serverWindows == nil check, because it would either have been nil, or be caught by the release above, which makes sure the old array is released (i.e. you won't leak) and you still get a new, working array.

--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Why does this keep sending EXC_BAD_ACCESS (From: Angel Caban <email@hidden>)
 >Re: Why does this keep sending EXC_BAD_ACCESS (From: April Gendill <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.