Afnetwork使用

   ////////1.
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:@"http://www.raywenderlich.com/downloads/weather_sample/weather.php?format..." parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(@"JSON:%@",responseObject);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        NSLog(@"Error:%@",error);

    }];

    

    

    ///////2.
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *paramaters = @{@"format":@"json"};
    [manager POST:@"http://www.raywenderlich.com/downloads/weather_sample/weather.php" parameters:paramaters success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(@"JSON:%@",responseObject);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

         NSLog(@"Error:%@",error);

    }];

 

ps:
    #import "AFNetworking.h"
    #import 
    #import 

你可能感兴趣的:(Afnetwork使用)