• 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: NSXMLParser attributeDict enumeration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSXMLParser attributeDict enumeration (From: Martijn van Exel <email@hidden>)

  • Prev by Date: Re: figuring out which TableView I am?
  • Next by Date: Re: figuring out which TableView I am?
  • Previous by thread: NSXMLParser attributeDict enumeration
  • Next by thread: Re: NSXMLParser attributeDict enumeration
  • Index(es):
    • Date
    • Thread