Retrieving and displaying JSON data from URL (objective-C) - iphone

I am doing my homework to retrieve and display information about current weather from a JSON object using singleton pattern and ASIHTTPRequest.
The data from the URL in JSON format looks like this:
{ "data":
{ "current_condition":
[ {
"cloudcover": "51",
"humidity": "66",
"observation_time": "12:44 PM",
"precipMM": "0.0",
"pressure": "1002",
"temp_C": "30",
"temp_F": "86",
"visibility": "10",
"weatherCode": "116",
"weatherDesc": [ {"value": "Partly Cloudy" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0004_black_low_cloud.png" } ],
"winddir16Point": "S",
"winddirDegree": "170",
"windspeedKmph": "19",
"windspeedMiles": "12" } ],
"request": [ {
"query": "Lat 22.49 and Lon 114.14",
"type": "LatLon" } ],
"weather": [ {
"date": "2012-06-06",
"precipMM": "0.0",
"tempMaxC": "30",
"tempMaxF": "86",
"tempMinC": "26",
"tempMinF": "79",
"weatherCode": "113",
"weatherDesc": [ {"value": "Sunny" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
"winddir16Point": "SE",
"winddirDegree": "136",
"winddirection": "SE",
"windspeedKmph": "17",
"windspeedMiles": "11"
},
{
"date": "2012-06-07",
"precipMM": "0.1",
"tempMaxC": "30",
"tempMaxF": "87",
"tempMinC": "27",
"tempMinF": "80",
"weatherCode": "113",
"weatherDesc": [ {"value": "Sunny" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
"winddir16Point": "ESE",
"winddirDegree": "121",
"winddirection": "ESE",
"windspeedKmph": "15",
"windspeedMiles": "10"
},
{
"date": "2012-06-08",
"precipMM": "2.1",
"tempMaxC": "31",
"tempMaxF": "87",
"tempMinC": "27",
"tempMinF": "81",
"weatherCode": "116",
"weatherDesc": [ {"value": "Partly Cloudy" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png" } ],
"winddir16Point": "SSE",
"winddirDegree": "166",
"winddirection": "SSE",
"windspeedKmph": "17",
"windspeedMiles": "11"
},
{
"date": "2012-06-09",
"precipMM": "2.8",
"tempMaxC": "32",
"tempMaxF": "89",
"tempMinC": "28",
"tempMinF": "82",
"weatherCode": "176",
"weatherDesc": [ {"value": "Patchy rain nearby" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0009_light_rain_showers.png" } ],
"winddir16Point": "SSW",
"winddirDegree": "198",
"winddirection": "SSW",
"windspeedKmph": "17",
"windspeedMiles": "11"
},
{
"date": "2012-06-10",
"precipMM": "13.0",
"tempMaxC": "32",
"tempMaxF": "90",
"tempMinC": "28",
"tempMinF": "82",
"weatherCode": "116",
"weatherDesc": [ {"value": "Partly Cloudy" } ],
"weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png" } ],
"winddir16Point": "SW",
"winddirDegree": "220",
"winddirection": "SW",
"windspeedKmph": "22",
"windspeedMiles": "14"
} ]
}
}
In my AppData.m, the code looks like this:
- (void)requestFinished:(ASIHTTPRequest *)request {
NSData* responseData = [request responseData];
NSDictionary* resultDict = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:NULL];
NSDictionary* dataDict = [resultDict objectForKey:#"data"];
NSArray* myArray = [dataDict objectForKey:#"weather"];
if(weatherDataArray == nil)
weatherDataArray = [[NSMutableArray alloc] init];
[weatherDataArray setArray:myArray];
}
In myWeather.m, the code like this :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
myWeatherDataCell *cell = [tableView dequeueReusableCellWithIdentifier:#"myWeatherDataCell"];
// get the view controller's info dictionary based on the indexPath's row
NSDictionary* item = [[AppData sharedData].weatherDataArray objectAtIndex:indexPath.row];
cell.maxTempLabel.text = [item objectForKey:#"tempMaxC"];
cell.minTempLabel.text = [item objectForKey:#"tempMinC"];
cell.dateLabel.text = [item objectForKey:#"date"];
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
NSArray* weatherIconUrl = [item objectForKey:#"weatherIconUrl"];
NSDictionary* value = [weatherIconUrl valueForKey:#"value"];
NSString* urlString = [NSString stringWithFormat:#"%#",value];
NSData* url = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]];
cell.iconView.image = [UIImage imageWithData:url];
NSLog(#"weatherIconUrl" "%#",urlString);
return cell;
}
The tableview can show
cell.maxTempLabel.text = [item objectForKey:#"tempMaxC"];
cell.minTempLabel.text = [item objectForKey:#"tempMinC"];
cell.dateLabel.text = [item objectForKey:#"date"];
Except the iconview.image.
I try to use NSlog for
NSString* urlString = [NSString stringWithFormat:#"%#",value];
It can show looks like this:
2012-11-11 11:51:46.100 MyWeather[1583:1a603] weatherIconUrl(
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
)
2012-11-11 11:51:46.101 MyWeather[1583:1a603] weatherIconUrl(
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0017_cloudy_with_light_rain.png"
)
2012-11-11 11:51:46.102 MyWeather[1583:1a603] weatherIconUrl(
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
)
2012-11-11 11:51:46.102 MyWeather[1583:1a603] weatherIconUrl(
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
)
2012-11-11 11:51:46.103 MyWeather[1583:1a603] weatherIconUrl(
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"
)
But when I try to NSLog NSData* url, the result is (null).
So I think I am stuck in when "NSString* urlString" pass the data to "NSData* url".

As I said in my comment, your variable, "weatheIconURL", is actually an array with one object (a dictionary) in it, so you can use lastObject to fix that line. So those few lines need to be changed to:
NSDictionary* weatherIconUrl = [[item objectForKey:#"weatherIconUrl"] lastObject];
NSString* urlString = [weatherIconUrl valueForKey:#"value"];
NSData* url = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]];
cell.iconView.image = [UIImage imageWithData:url];

you can use JsonKit
to parse Jdon data and convert it into dictionary after getting the response from ASSIHTTPRequest
like this
- (void) requestFinished:(ASIHTTPRequest *)request {
// Use when fetching text data
NSString *responseString = [request responseString];
// Json dictionary
NSDictionary *resultsDictionary = [responseString objectFromJSONString];
}
in your case if you wanna get the cloudcover you may say
NSString *cloudCover =[[[resultsDictionary objectForKey:#"data"]objectForKey:#"current_condition"] objectAtIndex:0];
hope that helps

Related

how to json parse with components Separated By String

im new to parsing JSON and im trying a simple task, to retrieve a URL from a forecast weather json file.
Here i parse the json and i NSLog the contents of each component of the data:
NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&myError];
NSArray *data = [res objectForKey:#"data"];
NSLog(#"data=%#",data);
NSArray *results = [data valueForKey:#"weather"];
NSLog(#"weather=%#",results);
NSArray *results1 = [results valueForKey:#"tempMaxC"];
NSLog(#"tempMaxC=%#",results1);
NSArray *results2 = [results1 valueForKey:#"weatherIconUrl"];
NSLog(#"weatherIconUrl=%#",results2);
The problem is that when i get the WeatherIconUrl it comes with this format
"http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
and i cant get the url itself without the quotation marks, i tried using nsrange and componentsSeparatedByString but it always gives me this error:
[__NSArrayI componentsSeparatedByString:]: unrecognized selector sent to instance
JSON from server:
{
"data": {
"current_condition": [
{
"cloudcover": "0",
"humidity": "73",
"observation_time": "12:19 PM",
"precipMM": "0.0",
"pressure": "1021",
"temp_C": "23",
"temp_F": "73",
"visibility": "10",
"weatherCode": "113",
"weatherDesc": [
{
"value": "Sunny"
}
],
"weatherIconUrl": [
{
"value": "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
}
],
"winddir16Point": "NW",
"winddirDegree": "320",
"windspeedKmph": "17",
"windspeedMiles": "11"
}
],
"request": [
{
"query": "Fanzeres, Portugal",
"type": "City"
}
],
"weather": [
{
"date": "2012-09-12",
"precipMM": "0.0",
"tempMaxC": "28",
"tempMaxF": "83",
"tempMinC": "17",
"tempMinF": "63",
"weatherCode": "113",
"weatherDesc": [
{
"value": "Sunny"
}
],
"weatherIconUrl": [
{
"value": "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
}
],
"winddir16Point": "NW",
"winddirDegree": "312",
"winddirection": "NW",
"windspeedKmph": "16",
"windspeedMiles": "10"
},
{
"date": "2012-09-13",
"precipMM": "0.0",
"tempMaxC": "33",
"tempMaxF": "91",
"tempMinC": "17",
"tempMinF": "63",
"weatherCode": "113",
"weatherDesc": [
{
"value": "Sunny"
}
],
"weatherIconUrl": [
{
"value": "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
}
],
"winddir16Point": "N",
"winddirDegree": "8",
"winddirection": "N",
"windspeedKmph": "10",
"windspeedMiles": "6"
}
]
}
}
Sorry for my bad english and please correct me if im doing this wrong, thanks in advance
use objectForKey instead of valueForKey when getting the array from #"weatherIconUrl" then get the string into NSString e.g.
NSString *weatherIconUrlString = [results2 objectAtIndex:0]
to check that this is a valid url, use the canHandleRequest method of NSURLConnection, e.g.
NSURL *url = [NSURL URLWithString:weatherIconUrlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
BOOL canGo = [NSURLConnection canHandleRequest:request];
If you truly have quotes surrounding your URL, then try something like this:
NSString *someURLString = [results2 objectAtIndex:0];
NSString *quotesRemoved = [someURLString stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:#"\""]];
putting the server's output through jsonLint.com gives an easier to read format of the json.
The code below now gets the weather icon url as required. It assumes the json has been downloaded as an NSData object called jsonData, and doesn't check for which date the data refers to.
NSError *error = nil;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves
error:&error];
NSArray *data = [jsonDict valueForKey:#"data"];
NSArray *weather = [data valueForKey:#"weather"];
NSArray *weatherIcon = [[weather objectAtIndex:0] valueForKey:#"weatherIconUrl"];
NSString *url = [[weatherIcon objectAtIndex:0] valueForKey:#"value"];
The resulting url is used in an NSURLRequest and shown in a webview

how is the code for parsing Json parsing?

Hi I have implemented code for parsing the below response as follows but it is not working properly:
NSString *req = [NSString stringWithFormat: #" My URL"];
NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue];
NSDictionary *resultsDict = [googleResponse valueForKey: #"eventtitle"];
What is the code for parsing the below response? Please give me solution.
{
"AlansHarleyEvents": [
{
"id": "3",
"eventtitle": "22nd Annual Pig Roast",
"eventdate": "April 22nd 8am-5pm"
},
{
"id": "4",
"eventtitle": "Poker Run",
"eventdate": "April 28th 8am at Shooters"
},
{
"id": "5",
"eventtitle": "Kickstands for kids",
"eventdate": "May 12th 8am-5pm"
},
{
"id": "6",
"eventtitle": "Ride for the Cure",
"eventdate": "May28th 8am Free Drinks!"
},
{
"id": "7",
"eventtitle": "Veterans Ride",
"eventdate": "June 10th 9am #City Hall"
},
{
"id": "8",
"eventtitle": "Biker Beach Bash",
"eventdate": "June 28th 8-5pm # The Pier"
},
{
"id": "10",
"eventtitle": "22nd Annual Pig Roast",
"eventdate": "April 22nd 8am-5pm"
},
{
"id": "11",
"eventtitle": "Poker Run",
"eventdate": "April 28th 8am at Shooters Lounge"
},
{
"id": "12",
"eventtitle": "22nd Annual Pig Roast",
"eventdate": "April 22nd 8am-5pm"
},
{
"id": "13",
"eventtitle": "Swamp Run",
"eventdate": "April 22nd 8am-5pm"
}
]
}
If your resultsDict contains the above JSON response then you can parse it as :
NSString *req = [NSString stringWithFormat: #" My URL"];
NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue];
NSDictionary *resultsDict = [googleResponse valueForKey: #"eventtitle"];
NSMutableArray *resultArray = [resultsDict valueForKey:#"AlansHarleyEvents"];
for(int i = 0; i<[resultArray count]; i++)
{
NSLog(#"%#",[[resultArray objectAtIndex:i] valueForKey:#"id"]) ;
NSLog(#"%#",[[resultArray objectAtIndex:i] valueForKey:#"eventtitle"]) ;
NSLog(#"%#",[[resultArray objectAtIndex:i] valueForKey:#"eventdate"]) ;
}
NSJSONSerialization Class is the Native Class for only iOS 5 and above
http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html
For any iPhone OS version means you can go for JSONKit:
https://github.com/johnezang/JSONKit
Yu can use NSJSONSerialization object with IOS 5
NSDictionnary *jsonObject = [NSJSONSerialization JSONObjectWithData:resultsDict options:NSJSONReadingMutableContainers error:&error];

How to implement code for getting latitude and longitude?

Hi all, how to get latitude and longitude values of location? I am trying using below code but I am getting wrong response, I need your help to solve the problem.
- (CLLocationCoordinate2D) geoCodeUsingAddress:(NSString *)address
{
NSString *city,*state,*zip;
city=#"Hyderabad";
state=#"Andrapradesh";
zip=#"22345";
address=city,state,zip;
NSLog(#"##########%#",address);
double latitude = 0, longitude = 0;
NSString *esc_addr = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *req = [NSString stringWithFormat:#"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%#", esc_addr];
NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:req] encoding:NSUTF8StringEncoding error:NULL];
NSLog(#"333333%#",result);
if (result) {
NSScanner *scanner = [NSScanner scannerWithString:result];
NSLog(#"##########%#",scanner);
if ([scanner scanUpToString:#"\"lat\":" intoString:nil] && [scanner scanString:#"\"lat\":" intoString:nil]) {
[scanner scanDouble:&latitude];
NSLog(#"4444444%#",scanner);
NSLog(#"5555%#",latitude);
if ([scanner scanUpToString:#"\"lng\":" intoString:nil] && [scanner scanString:#"\"lng\":" intoString:nil]) {
[scanner scanDouble:&longitude];
NSLog(#"6666%#",scanner);
NSLog(#"7777%#",longitude);
}
}
}
CLLocationCoordinate2D center;
center.latitude = latitude;
NSLog(#"##########%#",latitude);
center.longitude = longitude;
return center;
}
333333 {
"results" : [
{
"address_components" : [
{
"long_name" : "Hyderabad",
"short_name" : "Hyderabad",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Ranga Reddy",
"short_name" : "R.R. District",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "Andhra Pradesh",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Hyderabad, Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.57944810,
"lng" : 78.69135810
},
"southwest" : {
"lat" : 17.23837080,
"lng" : 78.24014110
}
},
"location" : {
"lat" : 17.3850440,
"lng" : 78.4866710
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.55533690,
"lng" : 78.74278980
},
"southwest" : {
"lat" : 17.21459250,
"lng" : 78.23055219999999
}
}
},
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
2012-03-29 23:56:58.577 SVGeocoder[670:11603]
####
2012-03-29 23:56:58.578 SVGeocoder[670:11603] ##########(null)
Try this:
- (CLLocationCoordinate2D) geoCodeUsingAddress: (NSString *) address
{
CLLocationCoordinate2D myLocation;
NSString *esc_addr = [address stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString *req = [NSString stringWithFormat: #"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%#", esc_addr];
NSDictionary *googleResponse = [[NSString stringWithContentsOfURL: [NSURL URLWithString: req] encoding: NSUTF8StringEncoding error: NULL] JSONValue];
NSDictionary *resultsDict = [googleResponse valueForKey: #"results"];
NSDictionary *geometryDict = [resultsDict valueForKey: #"geometry"];
NSDictionary *locationDict = [geometryDict valueForKey: #"location"];
NSArray *latArray = [locationDict valueForKey: #"lat"]; NSString *latString = [latArray lastObject];
NSArray *lngArray = [locationDict valueForKey: #"lng"]; NSString *lngString = [lngArray lastObject];
myLocation.latitude = [latString doubleValue];
myLocation.longitude = [lngString doubleValue];
LogInfo(#"lat: %f\tlon:%f", myLocation.latitude, myLocation.longitude);
return myLocation;
}

How to fetch data from this specific json (iphone)

Can anyone tell me how to find the model from this ?
it is giving me null all the time
{
"Status": 200,
"Data": [
{
"id": "1",
"custno": "0000235",
"locno": "00001",
"mfg": "KABA-MAS",
"model": "Cencon Gen II",
"serial": "GF8912",
"install": "2011-10-01",
"removed": "0000-00-00",
"warranty": "2012-01-10",
"seragrno": "A",
"equiploc": "Testing",
"notes": "This is a test lock to test our system. I this is it good.",
"invoice": "A",
"eqtype": "Lock",
"plan": "1",
"status": "0",
"image": "cencon_main_1318703242.gif",
"pmrequired": "1",
"locktime": null,
"lockby": null,
"pmrequiredText": "Yes",
"statusText": "Active",
"planTypeText": "Plan I"
},
{
"id": "2",
"custno": "0000235",
"locno": "00001",
"mfg": "adsdad",
"model": "",
"serial": "",
"install": "2011-10-24",
"removed": "0000-00-00",
"warranty": "0000-00-00",
"seragrno": "",
"equiploc": "",
"notes": "",
"invoice": "",
"eqtype": "",
"plan": "",
"status": "-1",
"image": "",
"pmrequired": "0",
"locktime": null,
"lockby": null,
"pmrequiredText": "No",
"statusText": "Pending",
"planTypeText": null
}
]
}
I am not sure...but there should be some obj.value type of structure, like in javascript
u can access it using something like "responce.data.model"
assuming the JSON has been turned into an NSDictionary:
NSArray *items = [dictionary objectForKey:#"Data"];
for (item in items) {
NSLog(#"model = %#", [item objectForKey:#"model"]);
}
If you are looking for how to turn the JSON into an NSDictionary try:
iPhone/iOS JSON parsing tutorial
try this :
NSData *responseData;
NSMutableDictionary *response ;
NSString *urlStr = [NSString stringWithFormat:#"http://www.example.com"];
NSLog(#"%#",urlStr);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *json = [[[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding] autorelease];
response = (NSMutableDictionary *)[json JSONValue];
Then you'll have dictionary response. Now you can access it as
NSLog(#"%#",[response valueForKey:#"Data"] objectAtIndex:yourIndexValue] valueForKey:#"model"]);
Use SBJsonParser for parsing the response.
And "data" field is array of dictionary.
SBJsonParser *parser = [[SBJsonParser alloc] init];
// parsing the JSON
NSMutableDictionary *jsonDictionary = [parser objectWithString:response];
NSMutableArray *dataArray = [jsonDictionary objectForKey:#"data"];
So, u can use something like this:-
for(NSMutableDictionary *tempDictionary in dataArray)
{
NSLog(#"id is %#",[dataArray objectForKey: #"description"]);
}

Facebook sdk for ios read fan page wall

i want to read my fan page wall from my iPhone application, how i can do ?
Now i have this code for parse the graph api:
-(IBAction)parsing:(id)sender{
[facebook requestWithGraphPath:#"PAGE_ID/feed" andDelegate:self];
}
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(#"received response");
}
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
// NSArray *data = [result objectForKey:#"data"];
NSArray *from = [result objectForKey:#"from"];
if ([result objectForKey:#"from"]) {
for (NSDictionary *name in from) {
NSString *myName = [name objectForKey:#"name"];
[self.label2 setText:myName];
NSLog(#" Log: ", myName);
}
But don't work because he don't parse:
The json file i want to parse is this:
{
"data": [
{
"id": "105744066144184_231235146928408",
"from": {
"name": "Alberto ####",
"id": "1000013568710###"
},
"to": {
"data": [
{
"name": "########",
"category": "News/media",
"id": "##########"
}
]
},
"message": "\u00e8######################################",
"type": "status",
"created_time": "2011-09-02T18:30:59+0000",
"updated_time": "2011-09-02T18:30:59+0000",
"likes": {
"data": [
{
"name": "Luca #####",
"id": "###########"
}
],
"count": 1
},
"comments": {
"count": 0
}
ecc..
I use
NSArray *list = [result valueForKey:#"data"];
for (NSDictionary *dic in list) {
NSLog(#"id : %#",[dic valueForKey:#"id"]);
NSLog(#"type : %#",[dic valueForKey:#"type"]);
if ([[dic valueForKey:#"type"] isEqualToString:#"status"]) {
NSLog(#"- message : %#",[dic valueForKey:#"message"]);
}else if([[dic valueForKey:#"type"] isEqualToString:#"link"]){
NSLog(#"- link : %#",[dic valueForKey:#"link"]);
}else if([[dic valueForKey:#"type"] isEqualToString:#"photo"]){
NSLog(#"- icon : %#",[dic valueForKey:#"icon"]);
NSLog(#"- message : %#",[dic valueForKey:#"message"]);
}
NSLog(#"------");
}
adaydesign :)