Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-17-2010, 09:01 PM   #1 (permalink)
Code before baby wakes up
 
RobotWoods's Avatar
 
Join Date: Sep 2009
Posts: 189
RobotWoods is on a distinguished road
Default NSXMLparser and coordinate data problem

I'm trying to parse some XML...an example item has a few elements: name, day, latitude, longitude.

In the parsing, things look (according to log entries) just fine, but when I go to recall the information, I can get name and day, but latitude and longitude are zero'd out. Not sure why it's treating them differently, thoughts? Here is the parser code, and how I'm trying to recall the data:

PHP Code:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    if(!
currentElementValue){
        
currentElementValue = [[NSMutableString allocinitWithString:string];}
    else{
        [
currentElementValue appendString:string];}
}

- (
void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI
:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    
    if([
elementName isEqualToString:@"opentasks"])
        return;
    if([
elementName isEqualToString:@"task"]) {
        [
appDelegate.openTasks addObject:aTask];
        
        [
aTask release];
        
aTask nil;
    }
    else
        [
aTask setValue:currentElementValue forKey:elementName];
    
NSLog(@"Adding %@ as %@",currentElementValue,elementName);
//the above log entry shows correct value
    
[currentElementValue release];
    
currentElementValue nil;

then later

PHP Code:
...
latitude.text = [NSString stringWithFormat:@"%f",aTask.latitude];
... 
is back to 0.0000

Thanks so much for your help.
RobotWoods is offline   Reply With Quote
Old 06-17-2010, 11:00 PM   #2 (permalink)
Code before baby wakes up
 
RobotWoods's Avatar
 
Join Date: Sep 2009
Posts: 189
RobotWoods is on a distinguished road
Default

So it had nothing to do with the parsing, and was just how I had set up the "task"...most of the fields were strings, but I had the coordinates as floats. Now I store them as strings, and convert to float at usage.
RobotWoods is offline   Reply With Quote
Reply

Bookmarks

Tags
cllocation, latitude, nsxmlparser, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 329
9 members and 320 guests
Absentia, Chickenrig, Domele, fiftysixty, givensur, heshiming, michaelhansen, PixelInteractive, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:16 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0