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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:36:26+00:00 2026-05-24T18:36:26+00:00

I looked around but I could not find quite the solution to my problem

  • 0

I looked around but I could not find quite the solution to my problem anywhere.

The thing is I would like to get the data that is on a webpage of mine. For example, the content of my web page is “4|3|6” and I would like to have an array with 4,3,6.

I may say something stupid there but I don’t really know if my page is XML or HTML, because when I check the source code it just shows “4|3|6” for example.

So is there any way to do this or am I going to have to look into parsers ? And also, how to know of what type my page is ? (it’s name is typically “http://example.aspx?value=x” )

I know a lot of questions were asked about this and I apologize if I missed the one with my answer in it.

If it helps, here are the info on the page:

type: text/plain
Encoding: UTF-8

EDIT: So after trying Alex’s version, it seems I can’t get to retrieve the data. I think the problem is to get the NSString from the data, which is that line:

NSString *dataString = [[NSString alloc] initWithData:data          encoding:NSUTF8StringEncoding];

This line doesn’t give me a crash, but when I try to display it using
label.text=datastring;

it doesn’t display anything. And when I try to assign an NSArray from datastring using the @”|” separator, and try for example to display the first item of that NSArray, it gives me that error about index being out of bounds.

I am not at work right now so I can’t really test this but thanks for any ideas.

  • 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-24T18:36:26+00:00Added an answer on May 24, 2026 at 6:36 pm

    If the source code is just “4|3|6” it’s plain text. You can download it using NSURLConnection:

    NSURL *targetURL = [NSURL URLWithString:@"…"];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    

    Then you can create a string from the data and parse it:

    NSString *dataString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    NSArray *components = [dataString componentsSeparatedByString:@"|"];
    [dataString release];
    

    Now you’ll have the components in the resulting array. I’m assuming the data is encoded in ASCII, which might not be the case. And the download is synchronous, which means it will block the current thread. If you’re running the code on the main thread, you might want to dispatch it to a background thread so that you don’t block the UI. But that’s to worry about later, just get it working first.


    As for the asynchronous download, I don’t like the asynchronous NSURLConnection interface, as it’s quite a lot of work for what it does. It’s a pity that NSURLConnection does not support blocks. You can find some NSURLConnection extensions with blocks on the web, but that means relying on third-party code, which carries its own possible problems. One easy way to get the download happening in background is this:

    - (void) performDownload
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSData *downloadedData = /* synchronous NSURLConnection */;
        [self performSelectorOnMainThread:@selector(downloadDidFinish:)
            withObject:downloadedData];
        [pool drain];
    }
    
    - (void) downloadDidFinish: (NSData*) data {
        NSLog(@"Data ready: %@", data);
    }
    
    - (void) startDownload {
        [self performSelectorInBackground:@selector(performDownload) withObject:nil];
    }
    

    But you should learn about threading, run loops and autorelease pools before you start using this code, so that you know what you are doing.

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

Sidebar

Related Questions

Ok, I have looked around and could not find a solution to this problem.
I've already looked around but couldn't find the exact solution/problem I'm having right now.
I looked around on the Internet but could not find a proper answer: Is
I've looked around but could not find a way of simply including or rendering
I have looked around but could not find any answer to my question. Is
I've looked around but have yet to find a great solution the the following
I've looked around for a solution but it seems this is not a common
I have looked around and could not find any similar question. Here is the
I looked around, but couldn't find this on the internet, nor anywhere in the
I've looked around here for similar question but couldn't find any that solved my

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.