问题描述
我在ASIFormDataRequest中苦苦挣扎。
I am struggling in ASIFormDataRequest.
我想在iphone上的facebook上传一张照片,以便我在编程中使用ASIFormDataRequest,但它给我的错误如 _OBJC_CLASS _ $ _ 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];
}
我还添加了两个文件 ASIHTTPRequest .h
和 ASIFormDataRequest.h
并在我编写代码的地方导入它
I also added two files ASIHTTPRequest.h
and ASIFormDataRequest.h
and imported it where I written my code
I还添加了像 CFNetwork
,基金会
等框架
I have also added frameworks like CFNetwork
,Foundation
,etc
请帮我解决这个错误。
Please help me in solving this error.
推荐答案
我今天遇到了类似的问题。如果您使用的是iOS 5,请确保ASIHTTPRequest中使用的所有文件(扩展名为.m)都包含在项目的编译源中。您可以通过以下方式检查:project-> target-> build-phase-> compile source。
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.
如果是这样的话,请尝试添加所有文件并再次编译。再次,如果你使用ios 5,这次会抛出更多的错误。所有与ARC有关。要再次解决此问题,请转到编译源,选择所有库文件(仅选择不使用ios5 sdk的文件)并将其标记为-fno-objc-arc。这将关闭所选文件上的ARC。
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.
这篇关于ASIFormDataRequest中的错误“_OBJC_CLASS _ $ _ ASIFormDataRequest”,引自:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!