Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 953889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:07:25+00:00 2026-05-16T00:07:25+00:00

I syncing the data on my website to my app, I’m using NSXMLParser to

  • 0

I syncing the data on my website to my app, I’m using NSXMLParser to do this. The problem is I have all the fields on my database defined as Strings. The sync process works fine when everything is a string, but this is causing me heartache further down the line when I try and use this data for other purposes.

Can anyone help me with defining my fields with the correct data types for the sync process, code below:

.m

// Array for WORKOUT.
    NSMutableString *currentID, *currentUserID, *currentWalkID, *currentDate, *currentDistance, *currentRepeats, *currentType, *currentIntensity,
    *currentComments, *currentTime, *currentWeight, *currentHeight;

I know its something to do with this NSMutableString, obviously everything is defined as a string.

.h

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{           
    currentElement = [elementName copy];

    // Check for the WORKOUT details in the XML feed.
    if ([elementName isEqualToString:@"workout"]) 
    {
        // clear out our workout item caches...
        item = [[NSMutableDictionary alloc] init];
        currentID = [[NSMutableString alloc] init];
        currentUserID = [[NSMutableString alloc] init];
        currentWalkID = [[NSMutableString alloc] init];
        currentDate = [[NSMutableString alloc] init];
        currentDistance = [[NSMutableString alloc] init];
        currentRepeats = [[NSMutableString alloc] init];
        currentType = [[NSMutableString alloc] init];
        currentIntensity = [[NSMutableString alloc] init];
        currentComments = [[NSMutableString alloc] init];
        currentTime = [[NSMutableString alloc] init];
        currentWeight = [[NSMutableString alloc] init];
        currentHeight = [[NSMutableString alloc] init];
    }
}   


- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{     
    if ([elementName isEqualToString:@"workout"]) 
    {
        Workout *newWorkout = [NSEntityDescription insertNewObjectForEntityForName:@"Workout" inManagedObjectContext: self.managedObjectContext];

        // save values to an item, then store that item into the array...
        [item setObject:currentID forKey:@"workout_id"];
        [item setObject:currentUserID forKey:@"workout_user_id"];
        [item setObject:currentWalkID forKey:@"workout_walk_id"];
        [item setObject:currentDate forKey:@"workout_date"];
        [item setObject:currentDistance forKey:@"workout_distance"];
        [item setObject:currentRepeats forKey:@"workout_repeats"];
        [item setObject:currentType forKey:@"workout_type"];
        [item setObject:currentIntensity forKey:@"workout_intensity"];
        [item setObject:currentComments forKey:@"workout_comments"];
        [item setObject:currentTime forKey:@"workout_time"];
        [item setObject:currentWeight forKey:@"workout_weight"];
        [item setObject:currentHeight forKey:@"workout_height"];

        newWorkout.workout_id = currentID;
        newWorkout.workout_user_id = currentUserID;
        newWorkout.workout_walk_id = currentWalkID;
        newWorkout.workout_date = currentDate;
        newWorkout.workout_distance = currentDistance;
        newWorkout.workout_repeats = currentRepeats;
        newWorkout.workout_type = currentType;
        newWorkout.workout_intensity = currentIntensity;
        newWorkout.workout_comments = currentComments;
        newWorkout.workout_time = currentTime;
        newWorkout.workout_weight = currentWeight;
        newWorkout.workout_height = currentHeight;
        [self.workoutArray addObject:newWorkout];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    // save the characters for the current item...
    if ([currentElement isEqualToString:@"workout_id"]) {
        [currentID appendString:string];
    } else if ([currentElement isEqualToString:@"workout_user_id"]) {
        [currentUserID appendString:string];
    } else if ([currentElement isEqualToString:@"workout_walk_id"]) {
        [currentWalkID appendString:string];
    } else if ([currentElement isEqualToString:@"workout_date"]) {
        [currentDate appendString:string];
    } else if ([currentElement isEqualToString:@"workout_distance"]) {
        [currentDistance appendString:string];
    } else if ([currentElement isEqualToString:@"workout_repeats"]) {
        [currentRepeats appendString:string];
    } else if ([currentElement isEqualToString:@"workout_type"]) {
        [currentType appendString:string];
    } else if ([currentElement isEqualToString:@"workout_intensity"]) {
        [currentIntensity appendString:string];
    } else if ([currentElement isEqualToString:@"workout_comments"]) {
        [currentComments appendString:string];
    } else if ([currentElement isEqualToString:@"workout_time"]) {
        [currentTime appendString:string];
    } else if ([currentElement isEqualToString:@"workout_weight"]) {
        [currentWeight appendString:string];
    } else if ([currentElement isEqualToString:@"workout_height"]) {
        [currentHeight appendString:string];
} 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:07:26+00:00Added an answer on May 16, 2026 at 12:07 am

    XML can only carry strings. Wheather it’s an element’s inner text or the value of an attribute, in the end everything is just a string.

    If you want to send anything other via XML, the sending side has to encode it in a string and the receiving side has to decode the string. For that to work both sides have to agree on a format, for Example for an Integer value one possibility is to encode 125 as “125”, or a float 2.5 as “2.5”. If you are using this format for your numbers you can decode them by using the integerValue and floatValue of NSString.

    float test = [@"2.5" floatValue];
    

    There are some standard formats defined in xsd, that you could use, but that will not help you decode them, if you don’t have a parser that does this for you. (NSXMLParser is no such)
    If you are using other Formats look at NSScanner. For dates and time you would like to look at NSDateFormatter.

    If you need help converting please post the format you are using, that is an excerpt of your XML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 477k
  • Answers 477k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you asking whether or not it would be useful,… May 16, 2026 at 5:17 am
  • Editorial Team
    Editorial Team added an answer Hitting ESC does cancels editing the label of CListCtrl so… May 16, 2026 at 5:17 am
  • Editorial Team
    Editorial Team added an answer You will need to set DeferredLoadingEnabled, and then include every… May 16, 2026 at 5:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.