SIGBUS/SIGSEGV error problems
SIGBUS/SIGSEGV error problems
- Subject: SIGBUS/SIGSEGV error problems
- From: Mike Brinkman <email@hidden>
- Date: Mon, 11 Aug 2003 21:18:35 -0400
I can't figure out why this method is causing my application to crash:
- (void)updateSum
{
int i; // counter
float sum; // sum of NSNumbers
XObject *myObject;
sum = 0;
for (i = 0; i < [myArray count]; i++)
{
myObject = [[XObject alloc] init];
myObject = [myArray objectAtIndex:i];
// increment sum with floatValue of current object's amount
sum += [[myObject amount] floatValue];
// release myObject
[myObject release];
}
[sumField setFloatValue:sum];
}
All this method is supposed to do is sum the values from an NSNumber object
in an NSMuatableArray, and place the value in a field. XObject is a subclass
of NSObject. XObject releases all of its objects in its dealloc method and
calls [super dealloc].
updateSum gets called when I add another object to myArray. It works fine
with the [myObject release] method commented out, but I get a signal 10
(SIGBUS) error if it's there and I try to add another object to myArray. If
I try [myObject autorelease] I get a signal 11 (SIGSEGV) error.
Does myObject need to be released since it's a local instance of XObject?
I'm trying to be really careful about memory leaks.
_______________________________________________
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.