我正在尝试将一些数据从我的应用程序发送到 Web 服务器。
该应用程序应该做的是显示成员列表,在选择时显示他们的详细信息并允许编辑他们的详细信息。到目前为止,除了编辑之外的一切都在工作。
我收到的错误消息是
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“数据参数为零”
该应用程序运行良好,直到
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
看来 responseData 为空。我无法理解它,因为生成的 url 在输入浏览器时可以正常工作。
这是更新细节的全部代码
- (IBAction)submitEdits:(id)sender {
smdbs_AppData *appData = [smdbs_AppData sharedInstance];
NSString *loggedInID=appData.loggedInID;
NSString *member = [self.memberDetailModel objectAtIndex:3];
NSURL *urlLogin = [NSURL URLWithString:[NSString stringWithFormat:@"http://xxx/API.php?task=setMemberDetails&id=%@&mem_id=%@§ion=%@&firstName=%@&lastName=%@&membershipNo=%@&DOB=%@&gender=%@&school=%@&religion=%@ðnicity=%@&photoPerm=%@&swimPerm=%@&giftaid=%@&giftaidperson=%@&address1=%@&address2=%@&town=%@&county=%@&postCode=%@&homeTelNo=%@&mother=%@&motherMobile=%@&father=%@&fatherMobile=%@&other=%@&relationship=%@&otherTelNo=%@&email1=%@&email2=%@&doctor=%@&surgery=%@&docTelNo=%@&allergiesMed=%@&specialNeeds=%@&pack=%@&six=%@&joinedScouting=%@&joinedBeavers=%@&joinedCubs=%@&joinedScouts=%@&joinedYLs=%@&joinedHelpers=%@&joinedLeaders=%@&crbDate=%@&crbNo=%@", loggedInID, member, self.section.text, self.firstName.text, self.lastName.text, self.membershipNo.text, self.DOB.text, self.gender.text, self.school.text, self.religion.text, self.ethnicity.text, self.photoPerm.text, self.swimPerm.text, self.giftaid.text, self.giftaidperson.text, self.address1.text, self.address2.text, self.town.text, self.county.text, self.postCode.text, self.homeTelNo.text, self.mother.text, self.motherMobile.text, self.father.text, self.fatherMobile.text, self.other.text, self.relationship.text, self.otherTelNo.text, self.email1.text, self.email2.text, self.doctor.text, self.surgery.text, self.docTelNo.text, self.allergiesMed.text, self.specialNeeds.text, self.pack.text, self.six.text, self.joinedScouting.text, self.joinedBeavers.text, self.joinedCubs.text, self.joinedScouts.text, self.joinedYLs.text, self.joinedHelpers.text, self.joinedLeaders.text, self.crbDate.text, self.crbNo.text]];
dispatch_async(kBgQueue, ^{
NSData* editData = [NSData dataWithContentsOfURL:urlLogin];
[self performSelectorOnMainThread:@selector(EditData:)
withObject:editData waitUntilDone:YES];
});
}
- (void)EditData:(NSData *)responseData
{
NSError* error;
NSLog(@"%@",responseData);
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSString* success = [json objectForKey:@"success"];
if ([success isEqualToString:@"1"]) {
[self performSegueWithIdentifier:@"showMemberDetails" sender:nil];
}
}