Objective-C

Discussion in 'iOS Development' started by mrinquisitive, Sep 6, 2008.

  1. mrinquisitive

    mrinquisitive New Member

    Joined:
    Sep 6, 2008
    Messages:
    2
    Likes Received:
    0
    I am having trouble figuring out the best way to approach my problem. In a section of my code, I need to be able to take an input of a 10 digit number and have it stored in an array, where each digit in the number is a different element in the array.

    If anyone has any ideas as to how I should do this, I would greatly appreciate the help.
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    you could try inputting it as an NSString or converting it from a char, and then call NSString's _-length method to see how many characters are in it, and then from there run an integer loop to figure the character at the index of the integer.
  3. mrinquisitive

    mrinquisitive New Member

    Joined:
    Sep 6, 2008
    Messages:
    2
    Likes Received:
    0
    While I'm not new to coding, I am new to objective-c and was wondering if you could possibly give me a small example, in code.

    Thanks
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    i'm gonna be fairly brief on this i have places to be.

    Code:
    NSInteger stringCount = 0;
    
    for(stringCount=0;stringCount<=[yourArray count];stringCount++) {
            // handle what you need to do to detect the current character
    }

Share This Page