Re: EXC_BAD_ACCESS in an strange place
Re: EXC_BAD_ACCESS in an strange place
- Subject: Re: EXC_BAD_ACCESS in an strange place
- From: Clark Mueller <email@hidden>
- Date: Fri, 23 Aug 2002 10:33:35 -0600
>
a few thoughts:
>
>
(1) when you declare files did you do this:
>
>
static id files = nil; // make the assigment because static will not
>
be niled automatically.
No I didn't do this...
>
>
(2) files is too common, I would use a more descriptive symbol name.
I renamed, and this did not fix the problem...
>
>
(3) how did you init files array? with arrayWithCapacity: ? did you
>
retain it?
Well, the following is the code for my initializing the array. It is
initialized in a separate block of code from where it was being called
(but I'm sure the array was getting initialized):
>
filesArray = [[NSArray alloc] init];
>
>
while( file = [de nextObject] ){
>
if( [ig fileExists:[folder stringByAppendingPathComponent:file]] )
>
filesArray = [filesArray arrayByAddingObject:[folder
>
stringByAppendingPathComponent:file]];
>
>
NSLog(@"%d: %@", [filesArray count]-1, [filesArray
>
objectAtIndex:[filesArray count]-1]);
>
}
>
>
NSLog(@"[filesArray count] == %d", [filesArray count]);
Now, this was causing a crash. I added a line to the above code:
>
[filesArray retain]
And it worked fine.
I'm left then with my original question: What was happening? Why wasn't
my check for filesArray == nil catching this? Memory management really
gives me a headache.
Thanks,
Clark
_______________________________________________
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.