Advertisement
arkader

afn json

Jun 23rd, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)welcome
  2. {
  3.     /******************** Envoi de données POST au sereveur php et retourne un JSON ****************************/
  4.    
  5.     NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];
  6.     NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
  7.                             udid,@"UDID",
  8.                             nil];
  9.    
  10.    
  11.     AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
  12.                             [NSURL URLWithString:@"http://hive-concept.com/web/app_dev.php/initializeTable"]];
  13.    
  14.    
  15.     [client setDefaultHeader:@"Accept" value:@"application/json"];
  16.     [client setParameterEncoding:AFJSONParameterEncoding];
  17.    
  18.     [client postPath:@"" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
  19.        
  20.         //responseObject
  21.         NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  22.         NSLog(@"Data Sent - Response: %@", text);
  23.        
  24.         //TO DO
  25.         //NSLog(@"responseObject %@",[responseObject class]);
  26.         //NSLog(@"lala %@", (NSDictionary *)responseObject);
  27.        
  28.        
  29.        
  30.     } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  31.         NSLog(@"error %@", [error localizedDescription]);
  32.     }];
  33.    
  34.     /******************** Fin Envoie POST ****************************/
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement