従うことができる本当に良いチュートリアルを見つける前に、私はjsonの解析に問題がありました。json を解析するための独自の Web サービスを構築していたとき、同じ手順を実行しましたが、今、twitter の json-feed を解析しようとすると、空白が表示されます。これが私のコードです。
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData //1
options:kNilOptions
error:&error];
NSArray* itemNumber = [json objectForKey:@"posts"]; //2
NSUInteger numObjects = [itemNumber count];
arrayTweets = [[NSMutableArray alloc] init];
arrayTimes = [[NSMutableArray alloc] init];
if (numObjects != 0) {
int i = 0;
do
{
NSDictionary* loan = [itemNumber objectAtIndex:i];
NSString* text = [(NSDictionary*)loan objectForKey:@"text"];
[arrayTweets addObject:text];
NSString *time = [(NSDictionary*)loan objectForKey:@"created_at"];
[arrayTweets addObject:time];
i++;
} while (i < numObjects);
} else {
NSLog(@"Nej");
}
[tableTweet performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
"NSArray* itemNumber = [json objectForKey:@" posts "];" に注意してください。私の古いjson-feedはこのように見えていたので...
{"status":"ok","count":4,"count_total":4,"pages":1,"posts":[{"id":58,"type":
:[以前に「投稿」があったので機能していましたが、今ではtwitterフィードで次のように始まります:
[{"created_at":"Mon Aug 06 19:16:42 +0000 2012","id":232555817835048961,"...
そして、私は何をすべきかわかりません。これがばかげていることはわかっていますが、誰かが私に説明しない限り、私は学ぶつもりはないと思います.
どんな助けでも大歓迎です!