Re: NSXMLParser attributeDict enumeration
Re: NSXMLParser attributeDict enumeration
- Subject: Re: NSXMLParser attributeDict enumeration
- From: Drew Lawson <email@hidden>
- Date: Mon, 27 Apr 2009 11:26:20 -0400
According to Martijn van Exel:
> Hi all,
>
> This might be more of a C problem than a Cocoa problem per se.
> Enumerating the values of an attribute dictionary in NSXMLReader I try to
> set some members of a currentNode object (which does not represent an XML
> node, confusingly):
>
> NSEnumerator *enumerator = [attributeDict keyEnumerator];
> id key;
> while ((key = [enumerator nextObject])) {
> NSLog(@"considering key %@",key);
> if([key isEqualToString:@"lat"])
> {
> currentNode.lat = (double)[attributeDict objectForKey:key];
> }
>
> Member 'lat' is a double.
The structure member may be a double, but the dictionary object isn't.
I'm not familiar with NSXMLReader, but the dictionary probably has
a string of the attribute value.
> The above does not work. 'Pointer value used where
> float was expected'. So I should dereference?
>
> currentNode.lat = (double *)[attributeDict
> objectForKey:key];
>
> does not work either: 'error: incompatible type for argument 1 of
> 'setLat:''. I guess it wouldn't, because I'm casting an (id) to a pointer to
> a double I think, but I'm not sure how I should be doing this.
>
> martijn van exel -+- email@hidden -+- http://www.schaaltreinen.nl/
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
Drew Lawson | "Look! A big distracting thing!"
| -- Crow T. Robot.
|
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden