关于AFNetworking返回值为空,是哪里错了么?求指导
xcode吧
全部回复
仅看楼主
level 14
卖鱼的😘 楼主
+ (NSURLSessionDataTask *)userInfoGetWithBlock:(NSString *) account:(NSString *) password:(void (^)(UserInfo *userInfo, NSError *error))block {
password=[MyEncryption md5EncryptionPwd:password];
NSString *key=[MyEncryption getRandomNSString];
NSString *code=[MyEncryption base64EnCoded:[MyEncryption md5Encryption:key]];
NSString *ServiceUrl=[[NSString alloc] initWithFormat:@"/login?key=%@&user=%@&password=%@",key,code,account,password];
NSURLSessionDataTask *task= [[AFAppDotNetAPIClient sharedClient] GET:ServiceUrl
parameters:nil
success:^(NSURLSessionDataTask * __unused task, id JSON) {
NSDictionary *postsFromResponse = [JSON valueForKeyPath:@"details"];
UserInfo* crntUserInfo = [[UserInfo alloc] initWithAttributes:postsFromResponse];
if (block) {
block(crntUserInfo , nil);
}
} failure:^(NSURLSessionDataTask *__unused task, NSError *error) {
if (block) {
block(nil, error);
}
}];
return task;
}
单击事件输出为空,,,
-(IBAction)send:(id)sender{
NSURLSessionTask *task = [UserInfo userInfoGetWithBlock:@"testuser":@"123456":^(UserInfo *userInfo, NSError *error) {
if (!error) {
NSLog(@"test:%@",userInfo.photo);
}
}];
}
2014年08月02日 09点08分 1
1