Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C getting data from a web page
    text
    copied!<p>I looked around but I could not find quite the solution to my problem anywhere.</p> <p>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. </p> <p>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.</p> <p>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 "<a href="http://example.aspx?value=x" rel="nofollow">http://example.aspx?value=x</a>" )</p> <p>I know a lot of questions were asked about this and I apologize if I missed the one with my answer in it.</p> <p>If it helps, here are the info on the page:</p> <p>type: text/plain<br> Encoding: UTF-8</p> <p>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:</p> <pre><code>NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; </code></pre> <p>This line doesn't give me a crash, but when I try to display it using label.text=datastring;</p> <p>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.</p> <p>I am not at work right now so I can't really test this but thanks for any ideas.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload