• 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: newbie EXC_BAD_ACCESS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie EXC_BAD_ACCESS


  • Subject: Re: newbie EXC_BAD_ACCESS
  • From: Larry Fransson <email@hidden>
  • Date: Sun, 20 Mar 2005 03:19:16 -0800


On Mar 20, 2005, at 2:11 AM, Daniel Child wrote:
// INITIATION AND DEALLOCATION
- (id)init
{
if (self = [super init])
{
knownStrokes = [NSMutableArray arrayWithCapacity: 100];
[self fillKnownStrokes]; // puts a bunch of stroke descriptons in the array
}
return self;
}

Why would something like this be autoreleased or otherwise "bad access"?

It's probably because you're using a class method (+arrayWithCapacity:) to initialize knownStrokes and it doesn't appear you're doing anything to retain knownStrokes. Class methods like +arrayWithCapacity:, etc. (generally any method that doesn't involve an alloc and init) return an autoreleased object. It's up to you to retain it if you want it to stick around. You need to make a change. Either this

knownStrokes = [[NSMutableArray arrayWithCapacity:100] retain];

or this

knownStrokes = [[NSMutableArray alloc] initWithCapacity: 100];

My method for debugging signal 10 and 11 crashes is to look for objects I haven't retained and retain them, or to eliminate release messages sent to other objects until the crash goes away. Then I figure out why there was a problem.

Larry Fransson
Seattle, WA
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: newbie EXC_BAD_ACCESS
      • From: Jyrki Wahlstedt <email@hidden>
References: 
 >newbie EXC_BAD_ACCESS (From: Daniel Child <email@hidden>)

  • Prev by Date: Start application by dragging a file on it
  • Next by Date: Re: Start application by dragging a file on it
  • Previous by thread: newbie EXC_BAD_ACCESS
  • Next by thread: Re: newbie EXC_BAD_ACCESS
  • Index(es):
    • Date
    • Thread