Created
January 10, 2012 07:24
-
-
Save mrsidique/1587640 to your computer and use it in GitHub Desktop.
Create New User
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
| - (IBAction)submitButtonClicked:(id)sender { | |
| CFUUIDRef uuid; | |
| CFStringRef uuidStr; | |
| NSString *uuidString; | |
| uuid = CFUUIDCreate(NULL); | |
| uuidStr = CFUUIDCreateString(NULL, uuid); | |
| uuidString = [NSString stringWithFormat:@"%@", uuidStr]; | |
| NSURL *url = [NSURL URLWithString:@"http://api.iwaqa.com/auth/new-signup"]; | |
| NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init]; | |
| NSArray *paramsArray = [NSArray arrayWithObjects:usernameTextField.text, passwordTextField.text, confirmPasswordTextField.text, emailAddressTextField.text, securityQuestionLabel.text, securityAnswerTextField.text, uuidString, @"1235",nil]; | |
| NSString *jsonString = [paramsArray JSONString]; | |
| //NSData *postData = [jsonString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; | |
| NSData *postData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
| [request setURL:url]; | |
| [request setHTTPMethod:@"POST"]; | |
| [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; | |
| [request setHTTPBody:postData]; | |
| GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher fetcherWithRequest:request]; | |
| [myFetcher beginFetchWithDelegate:self | |
| didFinishSelector:@selector(myFetcher:finishedWithData:error:)]; | |
| } | |
| - (void)myFetcher:(GTMHTTPFetcher *)fetcher finishedWithData:(NSData *)retrievedData error:(NSError *)error { | |
| if (error != nil) { | |
| NSLog(@"%@",error); | |
| NSString *jsonString = [[NSString alloc]initWithData:retrievedData encoding:NSUTF8StringEncoding]; | |
| NSLog(@"%@",jsonString); | |
| } | |
| else { | |
| //NSUserDefaults *waqaData = [NSUserDefaults alloc]; | |
| NSString *jsonString = [[NSString alloc]initWithData:retrievedData encoding:NSUTF8StringEncoding]; | |
| NSLog(@"%@", jsonString); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment