2012-03-29 6 views
-1

Ich habe Post-Wert zu Textfeld und es gibt JSON-String, wie Wert/JSON-String zu senden.Wie bekomme ich JSON String von der Webseite von Objective C

hier ist mein Code:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.donxebuyt.com/"]]; 
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 
[request setPostValue:txtFrom.text forKey:@"id_locA"]; 
[request setRequestMethod:@"POST"]; 

[request setCompletionBlock:^{ 
    NSString *responseString = [request responseString]; 
    NSLog(@"Response: %@", responseString); 
}]; 
[request setFailedBlock:^{ 
    NSError *error = [request error]; 
    NSLog(@"Error: %@", error.localizedDescription); 
}]; 

[request startAsynchronous]; 

Antwort

9
NSData *data=[NSData dataWithContentsOfURL:url]; 
NSError *error=nil; 
NSDictionary *response=[NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error:&error]; 
NSString* sth=[response objectForKey: @"some_your_key"]; 

sth ist eine neue Variable und post es, wie Sie es über

POST
Verwandte Themen