Created
January 11, 2012 02:08
-
-
Save mrsidique/1592528 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSArray *answers = [[NSArray alloc]initWithObjects:[waqaData objectForKey:@"Answer A"], [waqaData objectForKey:@"Answer B"], [waqaData objectForKey:@"Answer C"],[waqaData objectForKey:@"Answer D"], [waqaData objectForKey:@"Answer E"], nil]; | |
| NSArray *answerTypes = [[NSArray alloc]initWithObjects:answerAType, answerBType, answerCType, answerDType, answerEType, nil]; | |
| NSString *question = [waqaData objectForKey:@"textQuestion"]; | |
| NSString *groups = [NSString stringWithFormat:@"%@",[[waqaData objectForKey:@"groups"] objectAtIndex:0]]; | |
| NSString *answersString = [answers JSONString]; | |
| NSString *answerTypesString = [answerTypes JSONString]; | |
| NSString *latitude = [waqaData objectForKey:@"latitude"]; | |
| NSString *longitude = [waqaData objectForKey:@"longitude"]; | |
| NSString *radius = [waqaData objectForKey:@"radius"]; | |
| NSArray *postArray = [[NSArray alloc]initWithObjects:question, groups, answers, answerTypes, latitude, longitude, radius, nil]; | |
| NSString *jsonString = [postArray JSONString]; | |
| NSMutableData *postData = [[jsonString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]; | |
| NSURL *url = [NSURL URLWithString:@"http://api.iwaqa.com/waqa/new"]; | |
| ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; | |
| [request setRequestMethod:@"POST"]; | |
| [request setDelegate:self]; | |
| [request setPostBody:postData]; | |
| [request setRequestHeaders:[NSMutableDictionary dictionaryWithObjectsAndKeys:[waqaData objectForKey:@"cookie"], @"Cookie", @"multipart/form-data", @"Content-Type", nil]]; | |
| [request startAsynchronous]; | |
| } | |
| } | |
| #pragma mark - ASIHTTPRequest Delegate Methods | |
| - (void)requestFinished:(ASIHTTPRequest *)request | |
| { | |
| // Use when fetching text data | |
| NSLog(@"%@", [request responseString]); | |
| NSLog(@"%@", [request responseHeaders]); | |
| NSString *jsonString = [[NSString alloc]initWithData:[request responseData] encoding:NSUTF8StringEncoding]; | |
| NSLog(@"%@", jsonString); | |
| [self dismissModalViewControllerAnimated:YES]; | |
| // Use when fetching binary data | |
| //NSData *responseData = [request responseData]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment