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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:49:48+00:00 2026-05-29T05:49:48+00:00

I suddenly just thought of this and got stuck deciding which data type should

  • 0

I suddenly just thought of this and got stuck deciding which data type should I use to store an IP Address?

I have thought of NSString; But if I would need the last digit for identifications, should I use float or double? And that is also another problem, since when can float or double have more than 1 decimal point?

I am probably asking the question wrongly, because I really don’t know how to ask this.

The IP Address comes from an XML format <IP>192.168.1.1</IP>. Any idea how I should do this?

  • 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-29T05:49:48+00:00Added an answer on May 29, 2026 at 5:49 am

    Use NSString. You are not going to do arithmetic with it. If you need the separate components you can use NSArray, but NSString will serve you well for just storing the IP address.

    In response to your needs, you can always obtain the last character in your string using the NSString method:

    NSString *lastCharacter = [ip_string substringFromIndex: [ip_string length] - 1];
    

    Where ip_string is the string holding the IP address.

    Edit in response to comment:

    Logan’s code is storing each element in the IP address separated by a period into an array. So if the IP address is 192.168.1.1, the array will equal (192, 168, 1, 1).

    My code is storing the entire IP address in a string, and then obtaining the last character in that string. [ip_string substringFromIndex: [ip_string length] - 1] is just obtaining the last character in the string containing the IP address. The last character can be found at minus one character.

    So if the IP address is 192.168.1.1, the lastCharacter string will just contain the number 1.

    I suggested that code because you stated that you needed to do something with the last character in your IP address string, and my code shows how you can obtain the last character.

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

Sidebar

Related Questions

Just when I thought I've understood this topic completely, I'm back to basics. I
I've been wracking my brain on this problem, here , and suddenly thought to
I had this embedded map working just fine and now suddenly it just shows
suddenly we have to save kanji (Japanese) in a couple of columns of two
I suddenly have Run and Search in the menubar of my RCP application. Is
I'm receiving suddenly this error on a Win2003 Server Web Application: Microsoft VBScript runtime
I got a thread that is just banishing.. i'd like to know who is
I had the following check in my jQuery which I thought was working fine
I'm not sure if this is in cucumber really, but just in case some
I was happily working with HSQLDB by just having my DB URL like this:

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.