-[NSURL objectAtIndex:]: unrecognized selector sent to instance 0x4e1d6d0 ASIHTTPRequest
I'm formatting an ASIHTTPRequest to send array data to a server. I have an array for keys (propertyKeys) and an array for the information (propertyValues) and have created a loop to set the post and key values as such.
for(int i = 0;i<13;i++){
[request setPostValue:[pr开发者_JAVA技巧opertyValues objectAtIndex:i] forKey:[propertyKeys objectAtIndex:i]];
}
I am getting the following error, however:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL objectAtIndex:]: unrecognized selector sent to instance 0x4e1d6d0'
I tried to look up the documentation for AHIHTTPRequest but the site seems to be down.
Is that error happening within the code that you posted, or elsewhere? Running the app in debug mode (Cmd-Y) will let you follow the stack trace up to see exactly where a crash happened.
That said, if the crash is happening within what you posted, it probably means that either propertyKeys
or propertyValues
has been deallocated and that its pointer is now garbage. Make sure they aren’t getting released or autoreleased by the time you get to that part of your program.
You have accidentally assign an NSURL
rather than an NSArray
to either properyValues
or propertyKeys
. Check what they are in the debugger at this point.
In many cases, the compiler will have thrown a warning when you did this. Make sure your code has no warnings. In Objective-C, warnings are almost always errors, and should never be ignored.
精彩评论