Help Uploading Image iPhone
Greetings,
I'm uploading an image to my server using the following code:
http://cocoadev.com/index.pl?HTTPFileUploadSample
However, when I go to upload the image, I keep getting the following exception and I'm not quite sure what it means:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSURL URLWithString:filePath:delegate:doneSelector:errorSelector:]: unrecognized selector sent to class 0x3ea4f8a8'
Here is the bit of code that's causing this exception:
[[Uploader alloc] initW开发者_Go百科ithURL:[NSURL URLWithString:@"http://www.mysite.com/driver/ajax/uploadPhoto.1.php"
filePath:@"/Users/someone/foo.jpg"
delegate:self
doneSelector:@selector(onUploadDone:)
errorSelector:@selector(onUploadError:)]];
I'm not quite sure what these selectors "onUploadDone:" and "onUploadError:" are all about. Do I need to implement these methods?
Any insight greatly appreciated.
Many thanks in advance,
You are missing a ]
behind your URL. You want to call NSURL's method URLWithString
and pass the result as an argument to initWithURL:filePath:delegate:doneSelector:errorSelector:
And yes, you have to implement onUploadDone
and onUploadError
.
精彩评论