JSON GET and POST - ios

I am learning iOS app development.
I have JSON data coming from one of the sites in the form of Dictionary within an Array and within that Dictionary I have another Array and that contains another Dictionary.
for ex ,
Now I want to deserialize it and use it in my iOS app and also I have to post some data like a comment back to the server.The comment by teacher will be a POST to the server.
I hope the question makes sense.
I am stuck on how to deserialize this and use POST to server.
Any help is appreciated. Thanks in advance.

There are a couple of parts to your question:
1) To get the JSON data into a format which can easily be manipulated by your program, it's easiest to take an existing open-source JSON parser library and integrate it into your app. I like SBJSON. If you go to that site, it has instructions on including and using the library in your project.
2) To post a reply to the server, you need to know what format it expects the data in. Is your app interacting with an existing website (where a user could go to a page and fill out a form), or is it talking to an API?

Related

How can I pull and store data from a website?

My school recently got a new grade book software, and personally, I don't like the layout. I decided that I wanted to program my own, but my only snag is that I don't know how to pull my grades from the website. All I would need are my percentages (ints) in each subject. Once I had them stored I would be able to do the rest. Is there a way to do this in swift?
Thanks so much!!
You can not get website data without API call. You need an API giving data either in JSON or XML, then you have to call that service using Alamofire and there are number of methods to store data like realm database, NSDefaults etc.

Get JSON data from a specific URL in swift

What Im trying to do is get the data from this specific url https://www.globalmoneyworld.com/global-media-blog
Once I get the JSON data, Im positive I know how to use it. Ive made several apps in class that touch on this, one was a weather app, the other pulled blog posts from the guardian. The guardian app was more of what I waned to learn than the weather app.
The problem Im running into is that I cannot figure out how to ask for the data. How to get this type of response
http://jsonplaceholder.typicode.com/users/1
this is the link I want to get the data from again
https://www.globalmoneyworld.com/global-media-blog
What kind of request do I need to type in using Alamofire to get JSON data from that specific url? And please guide me in the right direction if Im not asking the right question.
The website you linked returns HTML data, not JSON.
There is no type of request you can make using Alamofire that will give you JSON from an arbitrary URL. The only URLs that return JSON are from sites that allow queries that return JSON. The good news is that JSON is widely supported as a data exchange protocol.

Using Car2go Api for iOS app

Hi I am trying to get the list of all car2go cars and use it for a test application, the only problem is I do not know how to get the information. I have gotten a consumer key and secret key but the problem is I am unsure how to get the file using the api and then once I get the file I don't know how I would read it since it is using xml.
The response from the html is on this site
http://code.google.com/p/car2go/wiki/vehicles_v2_1
once I get the file I don't know how I would read it since it is using xml
You'll need to parse the response to extract the data you want. There are a number of ways to do that. For example, you could use NSXMLParser (which is included in Cocoa Touch), or you could use the TouchXML library, or you could use libxml.

How Can I Incorporate my WordPress Blogs into an iOS app?

How Can I Incorporate my WordPress Blogs into an iOS app? I have a beautiful word press site and I want to create a native iOS app. I have knowledge of coding for iOS, but I just don't know how I would go about showing all the latest blogs that are up in a beautiful way.
Thanks in Advance!
There are many ways you can achieve that. Here is a list of things you need to do in order to make an iOS app for your WordPress blog:
1) You need to parse the data from your WordPress blog to display it inside your iOS app. You can do it by parsing your blog's RSS feed you can parse JSON.
2) If you are planning to parse the RSS feed, use NSXMLParser to do that. There are other third party libraries available that parse the XML feeds but i would suggest to go with the built in NSXMLParser as there is plenty of help available online for it.
3) If you are planning to parse JSON data, install Feed JSON plugin on your WordPress blog. Once installed, you can go to http://example.com/feed/json to get the JSON data. (You can replace example.com with your blog's URL)
4) To connect to the web services like XML feed and JSON on your blog, you can use third party libraries like AFNetworking or you can use Apple's built in libraries like NSURLConnection and other classes to connect and download the data from the webservice.
5) Here are some very easy tutorials for the steps above. How to Use NSURLConnection, How to fetch JSON or How To Parse RSS with NSXmlParser
You can start your app by completing the above steps and getting started.
6) After that one of the most important thing is to download images asynchronously in the UITableViewCells where you are displaying your blog posts. I would suggest you to download a video from Stanford University's iOS programming course on iTunes U that shows how to do it or you can simply find some tutorials or look for questions on StackOverflow.
7) Then you have to create a UIWebView and when the row of any blog post inside the UITableView is tapped, you can use the link to segue in the UIWebView to show the actual blog post. You can use didSelectRowAtIndexPath in order to pass data between view controllers.
8) Below the view controller that contains the UIWebView, you can add functions like stop, refresh, sharing on Facebook and Twitter etc.
9) As you can see that is a lot of work and business people just think that its easy to develop an iOS app but the truth is that it takes some time to completely package the app and submit to the App Store. You can also outsource your project by using service like Convert WordPress Blog To iOS App that is completely for free if you share revenue with them but its your choice and i recommend you to code it yourself to have complete ownership of you app.
Rest is just a matter of choice of different functions you would like to make in your app to stand out from the rest. You can add a Facebook style sliding navigation controller on the left side to create and parse specific categories on your blog, you can use Flipboard style swiping in your Web View etc etc. For that stuff there are a lot of third party libraries available.
Hope this helps!
You can read an answer of mine about cloud based ios apps (the db is online) here:
press me
now as i said, to get info from the server you need to use JSON, in wordpress there is a very good and simple plugin for that: JSON API
now the use of that is simple, you can see it in the notes: http://wordpress.org/plugins/json-api/other_notes/
but for example for getting the last posts in the system you need to run the url: http://www.example.org/api/get_recent_posts/
The /api means it's the plugin (you can change that in the settings) and the /get_recent_posts/ is the function.
there are many other functions like this one for everything you need and it can get more complicated than that based on what you want to get from the db.
After running the "query" and getting a response in JSON you need to use it:
Working with JSON in iOS 5 Tutorial
now for the running of the url i recommend to use AFNetworking
now all you need to do is use the json string you get for getting out info.
this would have some more issues like managing html codes you get in the content respons and so but it's the start, develop your way up :)

Searching Twitter feeds

I'm looking to take information from Twitter feeds such as removed posts. Is it possible to do this through some sort of string match search by looking for keywords, that is, "this post removed"?
This is for an Arduino project.
It should be. Twitter just turned off their old API, though, so as long as you're willing to get an API key, you should be fine (https://dev.twitter.com). Grab the data with loadBytes or loadStrings called on the API URL and then start walking through the data you got back (http://processing.org/reference/loadStrings_.htm) -- which in the new API will be JSON. You can use a JSON library to turn that into an actual object, but frankly if you want to do text matching, which you do, then there's really no need for Object repacking.

Resources