0

ばかげた質問。サンプルの AFNetworking コードを次の場所に貼り付けただけです。

NSURL *url = [NSURL URLWithString:@"https://gowalla.com/users/mattt.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]);
} failure:nil];

[operation start];

しかし、何も起こりません。操作を NSLog に出力すると、リクエストがキャンセルされたように見えます。

<AFJSONRequestOperation: 0x81655f0, state: isExecuting, cancelled: NO request: <NSURLRequest https://gowalla.com/users/mattt.json>, response: (null)>

私は何を間違っていますか?

4

1 に答える 1

0

あなたの最善の策は、失敗ブロックを追加し、その中で提供されている変数を調べることです

NSURL *url = [NSURL URLWithString:@"https://gowalla.com/users/mattt.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@"%@", [error localizedDescription]);
}];

[operation start];
于 2012-04-01T21:32:47.790 に答える