Weird Fix for EXC_BAD_ACCESS
Weird Fix for EXC_BAD_ACCESS
- Subject: Weird Fix for EXC_BAD_ACCESS
- From: Duncan Oliver <email@hidden>
- Date: Thu, 24 Jul 2003 12:56:24 -0500
I have a bit of code that tries to find the "owner" dictionary of an
object. Each item is a dictionary that consist of a NSString under key
"name" and an array of similar objects under key "contents" the code is
suppose to look for the parent, starting from the top array, collection:
- (NSMutableDictionary *)searchDeepArrayOfItem:(NSMutableDictionary
*)scope forObject:(NSMutableDictionary *)query;
{
NSEnumerator *enumerator;
NSMutableDictionary *object, *result;
NSMutableArray *array;
if (scope == nil)
array = collection;
else
array = [scope objectForKey:@"contents"];
if ([array indexOfObject:query] == NSNotFound)
{
enumerator = [array objectEnumerator];
while (object = [enumerator nextObject])
{
result = [self searchDeepArrayOfItem:object
forObject:query];
if (result != nil)
break;
}
}
else
result = scope;
return result;
}
The problem is that I always get a "EXC_BAD_ACCESS", unless I change
this:
result = [self searchDeepArrayOfItem:object forObject:query];
if (result != nil)
break;
to this:
NSLog(//any text will do here);
result = [self searchDeepArrayOfItem:object forObject:query];
if (result != nil)
break;
I can't figure out why adding an NSLog would allow the code to execute
properly. Any ideas?
Duncan Oliver
email@hidden
_______________________________________________
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.