首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASIFormDataRequest NSInvalidArgumentException

ASIFormDataRequest NSInvalidArgumentException
EN

Stack Overflow用户
提问于 2011-06-28 23:54:37
回答 1查看 640关注 0票数 0

我正在尝试通过以下代码使用ASIFormDataRequest

代码语言:javascript
复制
NSURL *url = [NSURL URLWithString: urlString];
ASIFormDataRequest *request = [ASIHTTPRequest requestWithURL:url];
[request addPostValue:@"json" forKey:@"json"];
[request setDelegate:self];
[request startAsynchronous];

代码总是在[request addPostValue:@"json" forKey:@"json"];行崩溃。我也尝试过setPostValue:forKey:,也有同样的结果。如果我注释掉addPostValue:forKey:行,请求就会通过(我可以在服务器上看到它),但是当然没有json数据。

我通过传入值的字符串json简化了这个问题。一旦我解决了这个问题,它实际上就是我的json格式的字符串。

下面是堆栈跟踪:

代码语言:javascript
复制
2011-06-28 08:49:29.344 Gleek[26170:207] *** Terminating app due to uncaught     exception     'NSInvalidArgumentException', reason: '-[ASIHTTPRequest addPostValue:forKey:]: unrecognized     selector sent to instance 0x5024400'
*** Call stack at first throw:
(
0   CoreFoundation                      0x010f85a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x0124c313 objc_exception_throw + 44
2   CoreFoundation                      0x010fa0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x01069966 ___forwarding___ + 966
4   CoreFoundation                      0x01069522 _CF_forwarding_prep_0 + 50
5   Gleek                               0x00006bab -[ProcedureDefDetailViewController toggleCompletedStatus:] + 1451
6   UIKit                               0x005e44fd -[UIApplication sendAction:to:from:forEvent:] + 119
7   UIKit                               0x00674799 -[UIControl sendAction:to:forEvent:] + 67
8   UIKit                               0x00676c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9   UIKit                               0x006757d8 -[UIControl touchesEnded:withEvent:] + 458
10  UIKit                               0x00608ded -[UIWindow _sendTouchesForEvent:] + 567
11  UIKit                               0x005e9c37 -[UIApplication sendEvent:] + 447
12  UIKit                               0x005eef2e _UIApplicationHandleEvent + 7576
13  GraphicsServices                    0x018b6992 PurpleEventCallback + 1550
14  CoreFoundation                      0x010d9944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15  CoreFoundation                      0x01039cf7 __CFRunLoopDoSource1 + 215
16  CoreFoundation                      0x01036f83 __CFRunLoopRun + 979
17  CoreFoundation                      0x01036840 CFRunLoopRunSpecific + 208
18  CoreFoundation                      0x01036761 CFRunLoopRunInMode + 97
19  GraphicsServices                    0x018b51c4 GSEventRunModal + 217
20  GraphicsServices                    0x018b5289 GSEventRun + 115
21  UIKit                               0x005f2c93 UIApplicationMain + 1160
22  Gleek                               0x00002a09 main + 121
23  Gleek                               0x00002985 start + 53
24  ???                                 0x00000001 0x0 + 1
)

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-28 23:58:59

答案很简单,你必须使用:

代码语言:javascript
复制
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

你使用的是,

代码语言:javascript
复制
ASIFormDataRequest *request = [ASIHTTPRequest requestWithURL:url];

只要改变这一点,它就会起作用。

始终确保使用正确的类构造函数初始化对象。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6509358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档