error in ASIFormDataRequest “_OBJC_CLASS_$_ASIFormDataRequest”, referenced from:

人盡茶涼 提交于 2019-12-23 19:20:27

问题


I am struggling in ASIFormDataRequest.

I want to upload a photo on facebook in iphone so that I used a ASIFormDataRequest in my programming but it give me error like _OBJC_CLASS_$_ASIFormDataRequest, referenced from:

I don't understand its meaning and how can I handle it

My code for uploading photo is as follows:

-(void)postphoto:(id)sender
 {
     UISegmentedControl* _segControl;    
     //ASIFormDataRequest *request;

     UIImageView *_imageView = [UIImageView alloc];// initWithImage: image];
     NSString *likeString;
     NSString *filePath = nil;
     if (_imageView.image == [UIImage imageNamed:@"angelina.jpg"]) {
         filePath = [[NSBundle mainBundle] pathForResource:@"angelina" ofType:@"jpg"];
         likeString = @"babe";
     } else if (_imageView.image == [UIImage imageNamed:@"depp.jpg"]) {
         filePath = [[NSBundle mainBundle] pathForResource:@"depp" ofType:@"jpg"];
         likeString = @"dude";
     } else if (_imageView.image == [UIImage imageNamed:@"maltese.jpg"]) {
         filePath = [[NSBundle mainBundle] pathForResource:@"maltese" ofType:@"jpg"];
         likeString = @"puppy";
     }
     if (filePath == nil) return;

     NSString *adjectiveString;
     if (_segControl.selectedSegmentIndex == 0) {
         adjectiveString = @"cute";
     } else {
         adjectiveString = @"ugly";
     }

     NSString *message = [NSString stringWithFormat:@"I think this is a %@ %@!", adjectiveString, likeString];

     NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
    //[ self setRequest:[ASIFormDataRequest requestWithURL:url]];
     request = [ASIFormDataRequest requestWithURL:url];
     [request addFile:filePath forKey:@"file"];
     [request setPostValue:message forKey:@"message"];
     //[request setPostValue:_accessToken forKey:@"access_token"];
     [request setDidFinishSelector:@selector(sendToPhotosFinished:)];

     [request setDelegate:self];
     [request startAsynchronous];

 }

I also added two files ASIHTTPRequest.h and ASIFormDataRequest.h and imported it where I written my code

I have also added frameworks like CFNetwork,Foundation,etc

Please help me in solving this error.


回答1:


I had a similar problem today. If you are using iOS 5 then make sure that all the files used from ASIHTTPRequest (which have a .m extension) are included in the project's compile source. you can check this by: project->target->build-phase->compile source.

if this is the case than try to add all the files and compile again. again if you are using ios 5 it will throw a lot more errors this time. all relating to ARC. to resolve this again go to the compile source, select all the library files (select only the file not using ios5 sdk) and flag them as "-fno-objc-arc". this will turn off the ARC on the selected files.




回答2:


you have to link your binary with the library which has ASIFormDataRequest too.



来源:https://stackoverflow.com/questions/5786285/error-in-asiformdatarequest-objc-class-asiformdatarequest-referenced-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!