Parsing/Delimiting a text string?

Discussion in 'iOS Development' started by Schfourteen, Apr 23, 2010.

  1. Schfourteen

    Schfourteen New Member

    Joined:
    Apr 23, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    3G iPod touch
    I just started working with xcode and objective-c. I'm creating an application that needs to delimit a string that is numbers that are separated by commas. I need to delimit the string and then pull certain numbers out. I've looked for parsing and delimiting tuts all over the internet and i can't seem to find any.

    I have a pretty good knowledge or VB.NET and a little bit of C#, Thanks

    Please Register or Log in to view images

  2. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    - Apple's NSString documentation, slightly modified
  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Alternatively, just get the components and get the numbers out of that using C, as you would any other array. There might be an NSString object, but a string is still nothing more than an array of characters. Delimit it the same way you would any other string. If you insist on using Objective-C for your stringwork, then just append '\0' or whatever to the end of the string using one of the appending API.
  4. Schfourteen

    Schfourteen New Member

    Joined:
    Apr 23, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    3G iPod touch
    Alright thanks guys!

    Now I'm trying to delimit this source from a web page. I have two ideas but I'm not sure if they will work. Sorry if they are confusing.

    1) When the search button is clicked, the text in it will be added to a query string. Is there anyway I can have it navigate to that page and grab the source without a web view? Then after it would grab the source I would put it into an array and delimit it into my labels.

    2) Same thing just have an invisible web view on the page and then just grab the source from that. Are either of these possible to pull off?

    Sorry I'm really new to Objective-C and it's very overwhelming!

    Please Register or Log in to view images


    Thanks for any help

    Please Register or Log in to view images

  5. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    No need to create a web view; use NSString's -[initWithContentsOfURL:encoding:error:] method
  6. Schfourteen

    Schfourteen New Member

    Joined:
    Apr 23, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    3G iPod touch
    Alright thanks

    Please Register or Log in to view images


    I took a look at it, but I have no idea where to declare it
    and how to make it so it calls it when the search button is clicked.
    And how do you set a path for an ipod?

    Gahh this is so frustrating cause I know what I want to do and I could easily do this in VB.NET

    Please Register or Log in to view images


    Do any of you guys have any suggestions for iPod/iPhone Dev books for beginners?
  7. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    You should probably start with easier examples... What you are trying to do is REALLY easy once you understand the App life cycle.
  8. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    Although that IS a possibility, Apple recommends not to use it that way (it's synchronous, so it could block the main thread. If you use it on a second thread, you're wasting resources, since Apple's synchronous URL methods are wrappers around the asynchronous).

    As Pelaez said, regardless of the above, I recommend you get into simpler things first and learn the basic 'structure' of Cocoa/MVC/iPhone apps.
  9. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    yeah, that's right. I wasn't thinking about such implications.

Share This Page