Re: NSMutableArray count causes EXC_BAD_ACCESS
Re: NSMutableArray count causes EXC_BAD_ACCESS
- Subject: Re: NSMutableArray count causes EXC_BAD_ACCESS
- From: Christiaan Hofman <email@hidden>
- Date: Mon, 16 Aug 2010 00:22:09 +0200
On Aug 16, 2010, at 0:12, Andrew Gehring wrote:
> I'm new to XCode /Obj-c, so please forgive my my transgressions...
>
> I have 'NSMutableArray *members;'
>
> I load the array with XML data:
>
> members = [[NSMutableArray alloc] init];
> NSArray *memberElements = [doc nodesForXPath:@"//member/value/string"
> error:&error];
> for (NSXMLElement *xmlElement in memberElements)
> [members addObject:[xmlElement stringValue]];
>
> I can "Log" the array, and it contains the expected data:
>
> NSLog(@"Members: %@", members);
>
> But when I try to count, I get a EXC_BAD_ACCESS
>
> NSLog(@"Count: %@", [members count]);
>
>
> Any help would be appreciated.
>
> Andrew
You're using the wrong string format specifier %@, which will interpret the count as a pointer to an object, and the object pointed to by that arbitrary number will almost certainly not exist.
Christiaan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden