NSString导致EXC_BAD_ACCESS,字符串太长了?

时间:2011-04-11 22:28:16

标签: iphone objective-c nsstring exc-bad-access

当我的应用程序达到此目的时,我会收到EXC_BAD_ACCESS

NSString *nameData = nameTextField.text;
NSString *emailData= emailTextField.text;
NSString *phoneData = phoneTextField.text;
NSString *serviceData =    serviceTextView.text;

NSString *post = [NSString stringWithFormat:@"email_address=&contents=&form_identifier=538b7271-df83-41f5-84b0-db0fed518ade&form_type=1&empty_form_msg=Please%20fill%20in%20something%20before%20submitting.&1_1_10_40_First%2BName=%@&2_1_20_30_Last%2BName=&3_1_25_25_Company=&4_1_30_999_Email=%@&5_1_40_10_Phone=%@&6_1_50_0_Address%2B1=&7_1_60_-10_Address%2B2=&8_1_70_-20_City=&9_3_80_-30_County=&10_3_90_-40_Postcode=&11_2_100_-50_Comments=%@&submit=Send",nameData,emailData,phoneData,serviceData];

这是因为此字符串中的数据太长了吗?

1 个答案:

答案 0 :(得分:6)

我怀疑stringWithFormat%个字符解释(有些?)作为格式元素,因此解释了超过4个参数。 (例如%20f将采用浮动参数)

尝试用%替换所有文字%@(即%%以外的所有文字)。 String Format Specifiers总结了NSString支持的所有格式。