I want to fetch data from my web server, and put it into a UITableView. This data includes three values for each row (eMail, Userid, and status (online or not)). Now what's the best way to print out this data on the Webserver that I can convert it into something like an Array in the App? How this works with one simple string I know, and I found JSON-Tutorials on the internet, but the links where you can download JSON for iOS SDK are not available. Or is there an even better way to fetch an Array from a server?
The server has to "print out" a multidimensional array with email, userid and status for each contact.
Thanks very much for help!
#import <JSON/JSON.h> doesn't work, the file wasn't found.
You need to use NSJSONSerialization (Only available in iOS 5)
Here is a link with a tutorial demonstrating how to use it: http://www.raywenderlich.com/5492/working-with-json-in-ios-5
For iOS 4 and below, you should check out the SBJSON Library.
Using the above methods, you can convert the data into an NSArray, of which can be used in a UITableView.
Related
I have following case to handle:
My mobile application ( Sencha Touch App wrapped in native container ) has around 5000 book titles. Now, I don't want application to ping server to get these books on his mobile. Application will need to access this data during run time. So should I
a) dump the data into sqlite at the time of installation of the application ? (First time run)
b) Fetch data from files only. ( I will be making sorting and querying operations over this data - may not be a good solution if I store the entire file in an array at once and process it further )
Kindly advice.
Create a JSON API to fetch your data from a database on the server.
You can store this data in JSON file and then use JSON proxy to load/sort/query it.
BUT its better to expose a web service, just like what Diodeus said.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
iPhone SDK Xcode 4.2 iOS 5- How do i send a json to url ? (POST and GET) [Resolved]
I have a seemingly easy question. I'm trying to send data from my iPad device to a server using JSON. The thing is, all tutorials I see about sending JSON to the server uses the POST method. My question is, is it possible to send JSON using the GET method? It will be really helpful if you can give me some pointers on how to do it. Thanks.
You should really convince your boss to either use JSON in the body of a POST or use GET Parameters in form of a GET:
http://www.example.com/?Argument1=Wert1&Argument2=Wert2
But the GET example will not be, as you can see, in form of a JSON. Indeed it would be possible to define a custom header where you put your json data in. But I would strongly advise against doing so because IMHO it is not the proper way
It's simple. JSON is actually sent via QueryString parameter. For instance to send a dictionary, use following format of URL
http://www.mywebsite.com/service.php?data={"key":"value", "key":"value"}
or an Array of Dictionaries as
http://www.mywebsite.com/service.php?data=[{"key":"value"}, {"key":"value"}]
Make sure you escape your url string properly
I would like to create a project but i don't really know how to organize it and what do i exactly need.
I want an application which has a tableview ( grouped section ), with a refresh ( pull down ) of the framework three20, then when the user refresh the uitableview, the app check the webservice and ( i guess ) get the JSON and update the tableview ( by populate a plist ? )
so what do i need ?
a webservice, with a backfront where i can update my json ?
my application which has a plist populated by the json received from the webservice ?
AND
i have another view, where the user can send to the webservice information about him and update it when he wants. he will have in the application a page where he can see his information that he sent to the webservice earlier.
ps : should i use coredata ?
hope you get what i wanted.
Thanks guys !
You could use coredata, i find it organizes everything much better, but there is of course an associated overhead with using it. You should definitely use it when you will be editing the information you have stored, sounds like per your requirement even though you do store the data, once you edit it you send it back to the web service, so you are not really modifying your stored data.
Therefore a p list would work just fine, but again there is nothing wrong with storing it in core data. Your general idea is correct, you will be calling your web service, parsing the JSON or XML that you get and refreshing your table with the data.
Depending on what communication protocol (SOAP, REST) and the response (JSON, XML) the Web service is using there are tools that will generate all you need for the communication, you don't really need to do all that by yourself.
could someone point me in the right direction in how i can parse data from a blog to an iphone. E.g. You have a table view displaying the posts of the blog, you select a table cell and text content is displayed. Are there any tutorials/examples on this?
I have a bit of experience with parsing data using JSON (parsed data from database to iphone) but unsure on where to start with this?
Thanks for an help..
What you want to do is use the Wordpress API. The flow goes like this:
Make an API call. This is a subject unto itself, but typically you'd use NSHTTPRequest and NSURLConnection to make the request.
Parse the result. I forget if you get XML back; you probably do; in that case there are tons of solutions for parsing, including NSXMLParser and libxml2.
Populate UITables, etc. with the retrieved information.
The Wordpress API is not that big or complex, but it's a bigger subject than I can really get into in the context of an SO answer, so I'll just refer you to the aforelinked documentation and wish you happy reading.
I learning Objective C, and I am going to develop some apps. I have a general question: How to get text information from the Internet into your app. Say you want the current title of Yahoo News. Do I need to use some PHP, or are there Objective-C specific classes to choose from?
Help is appreciated (code as well!), just anything that can help me take te step to exploring the new possibilities!
If I understand your question, I'd say the best way to do it would be to get the HTML source from the URL of your choosing as a string, then parse it to grab an attribute such as the title. Have a look at NSString and NSXMLDocument; they both let you instantiate them from a URL.
Here's a great way to do it:
Go to Yahoo Pipes, and create your "pipe" (basically a feed of one or many different data inputs on the web).
Publish: Select a format for Yahoo to host, for example as an RSS feed or in JSON.
UIWebView can then point to your pipe's URL. (Here's a tutorial on UIWebView)
Done.
Note that you can choose to get the feed as RSS, JSON, and other formats as well. Here is an example of a pipe I set up for the National Vulnerabilities Database as RSS, and the same feed as JSON.
ASIHttpRequest Will keep you sane.