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

newbie EXC_BAD_ACCESS


  • Subject: newbie EXC_BAD_ACCESS
  • From: Daniel Child <email@hidden>
  • Date: Sun, 20 Mar 2005 00:11:15 -1000

Hi All,

Still trying to work out a mysterious crash. I get EXC_BAD_ACCESS whenever I try to access an instance variable from one of my classes. I found an FAQ that talks about this, saying it could have been autoreleased too often, or the object was simply autoreleased already. I don't see how this could be happening. From a "ScratchPad" type of program, on keyDown I try to call a method on the variable sa.

- (void)keyDown:(NSEvent *)theEvent
if ( [keyChar isEqualToString:@"f"] ) {
[sa printKnownStrokes];
}
}

The variable sa was created in the init for the PadView (the controller part of the program) in which keyDown is found. The init for sa (of StrokesArray class) fills an array with StrokeDescriptions.

@interface StrokesArray : NSObject
{
int numInList;
NSMutableArray *knownStrokes; // filled with StrokeDescriptions
}

// 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;
}

- (void)dealloc
{
[super dealloc];
}

But later when I call [sa printKnownStrokes] I get the crash.

- (void)printKnownStrokes
{
int i;
StrokeDescription *sd;
NSEnumerator *strokesEnum = [knownStrokes objectEnumerator]); // CRASH HERE

while ((sd = [strokesEnum nextObject]) != nil)
{
[sd printStrokeDesc];
}
}

Why would something like this be autoreleased or otherwise "bad access"? Other variables also created as instance vars of the controller class (PadView) seem to have no problem, and I thought I was treating them exactly the same. Incidentally, someone else suggested an extremely efficient method with @selector, but the result is identical, so the problem must indeed be knownStrokes itself. I have been mystified for two days now. Thanks.

Daniel


 _______________________________________________
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: Larry Fransson <email@hidden>
  • Prev by Date: Re: Faking large arrays in bindings to satisfy sparse data...
  • Next by Date: Priting Multiple View -(Sorry to ask but i m :-(( )
  • Previous by thread: drag image out of NSTextView
  • Next by thread: Re: newbie EXC_BAD_ACCESS
  • Index(es):
    • Date
    • Thread