2013-07-17 68 views
-1

我有一個JSON代碼網頁:JSON到NSMutableArray裏與AFNetworking

[ 
    {"url":"event.com","name":"Event name","event":"Event"}, 
    {"url":"event.com","name":"Event name 2","event":"Event"}, 
    {"url":"event.com","name":"Event name 3","event":"Event 3sw"} 
] 

我需要這個數據被存儲在NSMutableArray,這樣,用一個循環:

[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]]; 
[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]]; 
[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]]; 

如何可能,也許與AFNetworking?

+0

入住這裏http://stackoverflow.com/questions/ 9252100/parsing-json-string-to-a-nsmutablearray –

回答

1

有許多不同的JSON解析器一個GitHub的倉庫。蘋果提供了一個叫做NSJSONSerialization

入住這裏進行了非常類似的問題:

How to use NSJSONSerialization

或者文檔:

http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html

+0

這並不能回答他的問題。他希望Foundation對象中的數據結構與JSON結構不同。 –

+0

我如何使用AFNetworking庫做到這一點? –

+0

看起來像他們內置的。按照這裏的例子:http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFJSONRequestOperation.html這裏是他們獲取json對象的一個​​例子https:// github .COM/AFNetworking/AFNetworking /維基/工具入門與 - AFNetworking#下載和解析JSON的 – utahwithak