2011-04-26 41 views
3

我掙扎在ASIFormDataRequest。

我要上傳Fa​​cebook上的照片在iphone讓我在編程中使用的一個ASIFormDataRequest,但它給我的錯誤,如_OBJC_CLASS_$_ASIFormDataRequest,從引用:

我不明白它的意義,我怎麼能處理它

我上傳照片的代碼如下:

-(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.hASIFormDataRequest.h並將其導入,我寫我的代碼

我還添加了框架,如CFNetworkFoundation

請幫我解決這個錯誤。

回答

0

你有你的二進制,其中有ASIFormDataRequest太鏈接庫。

+0

PL告訴我如何可以鏈接我新,所以我不知道PL告訴我 – Yogesh 2011-04-26 05:30:35

+0

它看起來像它的分佈的唯一來源(無xcodeproject)。只需將源代碼添加到項目中,並將源代碼編譯並鏈接到二進制文件(例如您的應用程序),就像任何其他源文件一樣。 – justin 2011-04-26 06:04:09

+0

感謝我還添加源UT斯達康,但給我的錯誤 – Yogesh 2011-04-26 06:06:36

6

我今天也有類似的問題。如果您使用的是iOS 5,請確保所有使用ASIHTTPRequest(擴展名爲.m)的文件都包含在項目的編譯源中。你可以通過以下方式來檢查:project-> target-> build-phase-> compile source。

,如果這是不是嘗試添加的所有文件,並重新編譯的情況。再次如果你使用ios 5,它會在這次拋出更多的錯誤。都與ARC有關。再次解決這個問題去編譯源,選擇所有的庫文件(只選擇不使用ios5 sdk的文件)並將它們標記爲「-fno-objc-arc」。這將關閉選定文件上的ARC。

+0

我想在2011年4月,那就是當這個問題被問。 2011年4月沒有iOS-5。 – 2012-03-22 05:50:18