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

Re: Weird Fix for EXC_BAD_ACCESS


  • Subject: Re: Weird Fix for EXC_BAD_ACCESS
  • From: Duncan Oliver <email@hidden>
  • Date: Fri, 25 Jul 2003 11:41:49 -0500

On Thu, 24 Jul 2003 12:56:24 -0500, Duncan Oliver <email@hidden>
said:
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?


On Thursday, July 24, 2003, at 09:54 PM, matt neuburg wrote:

What happens if you try initializing result to nil at the start?

I took your advice and initialize result to nil, and lo and behold, it didn't crash. If you know why that worked, I'd like to hear the reason. Anything to help me learn what I was doing wrong.

Also, what's "collection"? Are you sure it's okay? m.

collection is an array declared in the interface of the current controller object and initialize in awakeFromNib for the same object. Thanks.

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.

  • Follow-Ups:
    • Re: Weird Fix for EXC_BAD_ACCESS
      • From: matt neuburg <email@hidden>
  • Prev by Date: FoundationKit md5/checksum
  • Next by Date: Re: Weird Fix for EXC_BAD_ACCESS
  • Previous by thread: Weird Fix for EXC_BAD_ACCESS
  • Next by thread: Re: Weird Fix for EXC_BAD_ACCESS
  • Index(es):
    • Date
    • Thread