splicing NSURL URLWithString

Discussion in 'iOS Programming' started by FreedomApple, Oct 5, 2011.

  1. FreedomApple macrumors newbie

    Joined:
    Oct 2, 2011
    #1
    Hello everyone,
    I'm new to Objective C. What I'm trying to do is pull a list from my site that comes out like this:

    Code:
    item 1<br>\n
    item 2<br>\n
    item 3<br>\n
    etc<br>\n
    And using the code below it all comes out on one line when I want it to be split.

    Code:
        NSString *theWebString = @"http://mysite.com/getlist.php";
        NSURL *theWebURL = [NSURL URLWithString:theWebString];
        NSError *error;
        NSString *theWebPage = [NSString stringWithContentsOfURL:theWebURL 
                                                        encoding:NSASCIIStringEncoding
                                                           error:&error];
        NSArray *lines = [theWebPage componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\r\n"]];
        for (NSString* line in lines) {
            if (line.length) {
                NSLog(@"line: %@", line);
            }

    Anyone have any ideas how I would go about doing this?

    Thanks in advanced.
     
  2. FreedomApple thread starter macrumors newbie

    Joined:
    Oct 2, 2011
    #2
    Figured it out by doing the following

    Code:
    NSArray *lines = [theWebPage componentsSeparatedByString:@"<br>"];
     

Share This Page