Advertisement
Guest User

code

a guest
Sep 10th, 2010
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  NSString *post = @"email-email=test@email.com&password-password=testpassword";
  2. NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
  3. NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
  4. NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  5. [request setURL:[NSURL URLWithString:@"http://www.lockerz.com/auth/login/"]];
  6. [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
  7. [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  8. [request setHTTPBody:postData];
  9.  
  10.  
  11. NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
  12.  
  13.  
  14. if (theConnection) {
  15. NSLog(@"Connection succeeded!");
  16. receivedData = [[NSMutableData data] retain];
  17. NSString *text = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
  18. NSLog(@"Data received:%@", text);
  19. [text release];
  20. }
  21. else {
  22. NSLog(@"Error in connection!");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement