• 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: EXC_BAD_ACCESS in an strange place
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXC_BAD_ACCESS in an strange place


  • Subject: Re: EXC_BAD_ACCESS in an strange place
  • From: Isaac Sherman <email@hidden>
  • Date: Fri, 23 Aug 2002 13:16:33 -0400

on 8/23/02 12:33 PM, the method -(id)email@hidden:(id) sender:@"Clark
Mueller"; returned:


>> 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]

I recommend using an NSMutableArray and just using addObject:, less memory
management involved.

> 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.

Hmm. IIRC, I had a similar problem with NSString; I would alloc the
string, assign it a string, and myString==nil would return NO, even though
the string was empty. [myString compare:@""] would return NSOrderedSame,
however, and that's how I got around that. What I would suggest is perhaps
sending an isEqualTo: message, passing a freshly alloced empty array as the
argument.

HTH,


--
Isaac Sherman
MotaSoft Software
http://homepage.mac.com/huperzoevs/
_______________________________________________
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.

  • Follow-Ups:
    • Re: EXC_BAD_ACCESS in an strange place
      • From: Andreas Mayer <email@hidden>
References: 
 >Re: EXC_BAD_ACCESS in an strange place (From: Clark Mueller <email@hidden>)

  • Prev by Date: Re: NSDrawer, IB "springs", etc.
  • Next by Date: Re: Making a NSFormatter receive special keys
  • Previous by thread: Re: EXC_BAD_ACCESS in an strange place
  • Next by thread: Re: EXC_BAD_ACCESS in an strange place
  • Index(es):
    • Date
    • Thread