わかりました、私はこれにかなり慣れていないので、皆さんが感じるかもしれないことに苦労してきましたが、これは非常に簡単なエクササイズです。高低を調べましたが、これを行う方法に関する適切なチュートリアルやウォークスルーが見つかりません。基本的に、以下のコードを使用してツイートを取得しています。ツイートの「テキスト」部分のみが必要です。テーブルビューで「テキスト」キーを使用するために、NSDictionary から抽出するにはどうすればよいですか? 試してみ[dict objectForKey:@"text"]
ましたが、うまくいきません。'dict' に 'text' 属性が含まれていないようです。助けてくれてありがとう。
// Do a simple search, using the Twitter API
TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:
@"http://search.twitter.com/search.json?q=iOS%205&rpp=5&with_twitter_user_id=true&result_type=recent"]
parameters:nil requestMethod:TWRequestMethodGET];
// Notice this is a block, it is the handler to process the response
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if ([urlResponse statusCode] == 200)
{
// The response from Twitter is in JSON format
// Move the response into a dictionary and print
NSError *error;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
NSLog(@"Twitter response: %@", dict);
}
else
NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
}];