views:

201

answers:

1

I am trying write a simple image uploader using ASIHTTPRequest...

but at the code below....

[request setData:imageData withFileName:@"iphone.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

I get below warning msg....

warning: 'ASIHTTPRequest' may not respond to '-setData:withFileName:andContentType:forKey:'

not too sure whats wrong since i got all the import added at top too

#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"

Anyone have any idea why?

+1  A: 

Is your request an instance of ASIHTTPRequest?

Or is request an instance of ASIFormDataRequest?

To use the method -setData:withFileName:andContentType:forKey: your request must be an instance of ASIFormDataRequest.

If request is an instance of ASIHTTPRequest, the above method is definitely unavailable.

Secondly, if you look at the code in ASIFormDataRequest.h, you'll notice that ASIFormDataRequest is a subclass of ASIHTTPRequest:

@interface ASIFormDataRequest : ASIHTTPRequest

Therefore, it would be unnecessary to import ASIHTTPRequest.h if you just import ASIFormDataRequest.h and then instantiate request as an instance of ASIFormDataRequest.

An instance of ASIFormDataRequest will have all the same methods and properties of an instance of ASIHTTPRequest, with all the extra functionality of an ASIFormDataRequest request.

Alex Reynolds
Thanks a lot! I found the mistable my request was really wrong!! should of used ASIFormDataRequest and not ASIHTTPRequest!!
CBY