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 6024709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:11:43+00:00 2026-05-23T04:11:43+00:00

I am parsing XML that gets returned from a web service. If it is

  • 0

I am parsing XML that gets returned from a web service. If it is a valid user than I should be getting a long integer back. (for example: 2110504192344912815 or 2061128143657912001). If it is invalid then I get a 0. However if you see my code, I am getting negative values sometimes for userID and that is throwing my validation code hay wire. Any tips?

NSMutableString *loginString;
    NSInteger userID;

-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *) elementName
 namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{

    if ([elementName isEqual:@"GetUIDResult"]) {        
        userID = [loginString longLongValue]; / 0 if invalid password or LONG 
        [loginString release];
        loginString = nil;
    }   

}


//MY VALIDATION CODE..

    NSLog(@"The value of userID is: %ld",userID);

    if (userID > 0) {

    NSLog(@"YOU ARE NOW LOGGED IN");

    }else {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Validation Error" message:@"Unable to validate Login/Password combination" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
        [alert show];
        [alert release];

    }
  • 1 1 Answer
  • 0 Views
  • 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-23T04:11:44+00:00Added an answer on May 23, 2026 at 4:11 am

    check if loginString is not equal to @"0"

    if (![loginString isEqualToString:@"0"]) {
           NSLog(@"YOU ARE NOW LOGGED IN");
    }
    

    EDIT: I jut realised that your are actually asking why. Well, the documentation for NSString longLongValue methods says

    http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/20000154-intValue

    Return Value The long long value of
    the receiver’s text, assuming a
    decimal representation and skipping
    whitespace at the beginning of the
    string. Returns LLONG_MAX or LLONG_MIN
    on overflow. Returns 0 if the receiver
    doesn’t begin with a valid decimal
    text representation of a number.

    So, what is happening is that loginString’s value is an overflow, either because you are receiving it like this, or parsing it wrongly.

    EDIT 2:

    I saw that you edited your code. Now you are trying to store a long long value into a NSInteger type variabel:userID. This definitely will cause an overflow.

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

Sidebar

Related Questions

I'm looking for an XML parser that instead of parsing from an InputStream or
I am parsing some XML that will have a link such as the following
there is a xml document that i'm parsing to array.. how can i access
I am parsing an xml file with jquery and ajax. I noticed that it
I have an NSArray of (Product) objects that are created by parsing an XML
I am parsing and html/xml file. I am bit confused with the fact that
I'm working on some code that deals with parsing files (mainly XML, but there
I have a JS function that processes XML I GET from a server to
I'm obviously not getting something with this. I'm parsing an XML Document so I
I built a parsing application that reads xml files and populates an Excel workbook

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.