• 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: Jyrki Wahlstedt <email@hidden>
  • Date: Sun, 20 Mar 2005 14:53:05 +0200


On 20.3.2005, at 13:19, Larry Fransson wrote:


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.

Hi,
I can confirm this (probably => surely). I should know, I have done the same mistake in the beginning…
!
! Jyrki Wahlstedt
! Tinatie 3 A 2 mob. +358-40-502 0164
! FI-00440 Helsinki
!
! Our life is no dream; but it ought to become one and perhaps will.
! PGP key ID: 0x139CC386 fingerprint: F355 B46F 026C B8C1 89C0 A780 6366 EFD9 139C C386


_______________________________________________
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: Daniel Child <email@hidden>
References: 
 >newbie EXC_BAD_ACCESS (From: Daniel Child <email@hidden>)
 >Re: newbie EXC_BAD_ACCESS (From: Larry Fransson <email@hidden>)

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