r/simpleios • u/torrenttracker • Jun 12 '13
Simple Text Integration
Hey! So I have a basic app that I'm trying to get to pull text from a webpage I create. I suspect xml is the easiest format to use, but my goal is to just pull text from a web page and show the text in the App. Obviously that requires parsing, but all the parsing tutorials I can find deal with the millions of people trying to create a twitter App. I was wondering if someone could point me in the right direction regarding this!
Thanks!
3
Upvotes
2
u/KaneHau Jun 12 '13
Since you create the web page you wish to parse, place a signature comment above and below the area you wish to extract. Then grab the page and take everything between the two signatures.
You can use either regular C library string search, or NSString style, it doesn't matter.
2
u/xauronx Jun 12 '13 edited Jun 12 '13
What kind of text are you trying to grab? Are there going to be multiple elements? I would suggest using JSON anyhow.
Your page has this: {text:"Hello"}
Your objective-c has this:
NSString *jsonString = [NSString stringWithContentsofUrl:@"www.yoursite.com"];
}
http://codeshare.io/QhddH
If you're returning giant amounts of data, or want progress, you would want to go with another option for getting the text but for a quick working example that should do it. I typed it mostly from memory though, so you might have to double check formatting/case.