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

  • Follow-Ups:
    • Re: EXC_BAD_ACCESS in an strange place
      • From: Isaac Sherman <email@hidden>
    • Re: EXC_BAD_ACCESS in an strange place
      • From: Lance Bland <email@hidden>
  • Prev by Date: Making a NSFormatter receive special keys
  • Next by Date: Re: Distributed Objects return values...
  • 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