- (IBAction)register:(id)sender {
RequestHttpsClass *request = [[RequestHttpsClass alloc] initWithURL:[NSURL URLWithString:@"https://chanyouji.com/api/users.json"]];
request.HTTPMethod = @"POST";
NSString *str = [NSString stringWithFormat:@"email=%@&password=%@", self.users.text, self.passward.text];
request.HTTPBody = [str dataUsingEncoding:NSUTF8StringEncoding];
request.block = ^(NSData *data) {
NSLog(@"%@", [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableLeaves) error:nil]);
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"users" object:nil userInfo:@{@"users":[NSString stringWithFormat:@"%@", self.users.text]}];
}];
};
[request startAsync];
}
转载于:https://www.cnblogs.com/hsxblog/p/5037526.html