Eamorr
Eamorr

Reputation: 10012

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] initWithURL:[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,

Upvotes: 0

Views: 292

Answers (1)

Philipp
Philipp

Reputation: 1963

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.

Upvotes: 1

Related Questions