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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:06:38+00:00 2026-06-15T09:06:38+00:00

I am trying to withdraw values in a string in an iOS app. I

  • 0

I am trying to withdraw values in a string in an iOS app. I have an NSString in the format:

loc: 32 3203 292 293 321

I want to store all five integers into a 5 different int variables. The integers are of varying length. I am currently trying to determine which integer I am at using the space character as a guide, but I am having problems. There must be a simpler way to do it.

Here is what I have:

int length = [locationString length];
    NSMutableString * xStr, * yStr,* zStr, *tiltStr, *panStr;

    int charIndex = -1;
    unichar cur;

    for(i = 3; i < length; i++)
    {
        cur = [locationString characterAtIndex:i];
        if(cur == ' ') charIndex++;
        else
        {
            if(charIndex == 0)
            {
                [xStr appendString:[NSString stringWithCharacters:&cur length:1]];
            }
            else if(charIndex == 1)
            {
                [yStr appendString:[NSString stringWithCharacters:&cur length:1]];
            }
            else if(charIndex == 2)
            {
                [zStr appendString:[NSString stringWithCharacters:&cur length:1]];
            }
            else if(charIndex == 3)
            {
                [tiltStr appendString:[NSString stringWithCharacters:&cur length:1]];
            }
            else if(charIndex == 4)
            {
                [panStr appendString:[NSString stringWithCharacters:&cur length:1]];
            }
        }
    }

    NSLog(@"x String: %@", xStr);
    NSLog(@"y String: %@", yStr);
    NSLog(@"z String: %@", zStr);
    NSLog(@"tilt String: %@", tiltStr);
    NSLog(@"pan String: %@", panStr);

    if(xStr != NULL) xVal = [xStr integerValue];
    if(yStr != NULL) yVal = [yStr integerValue];
    if(zStr != NULL) zVal = [zStr integerValue];
    if(tiltStr != NULL) tiltVal = [tiltStr integerValue];
    if(panStr != NULL) panVal = [panStr integerValue];

But I am getting void strings each time. Anyone else do something like this before?

Thanks

  • 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-06-15T09:06:40+00:00Added an answer on June 15, 2026 at 9:06 am

    I would start with

    [locationString componentsSeparatedByString:@" "];
    

    This will give you an array with each string component.

    You can then ignore index 0, which would contain @”loc:”, and the remaining array indices will contain the data you will use.

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

Sidebar

Related Questions

I'm trying to build an app to move stocks around. I have products and
trying to figure out why this is happening - I have an input text
trying to get same string on tooltip as is in the Text e.g. Text=<%#
I'm trying to do Hide/Show for my application with withdraw()/deiconify() in Tkinter, but after
Trying to convert a perl script to php. In perl I have a hash
I am trying to write a function that copies a string parameter to the
I have just started learning C# so am pretty new... I am trying to
trying to get my first HTML/CSS uni assignment sorted but have become a bit
Trying to construct a query such that I have multiple statement specifying joins, each
I am trying to use the withdraw method, but it's not working. Here is

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.