2012-07-02 73 views
0

我發送一個帖子與對象加載器,並在輸出窗口中獲取此錯誤。僅供參考,我的didFailWithError:代表從未受到影響。不知道爲什麼。IOS restkit錯誤

`objectLoader:didFailWithError:]:` unrecognized selector `sent to class 0x123608` 

我怎麼知道什麼是0x123608?

我在AppDelegate類中設置路由器,並在AppDelegate中設置Mapping。

這裏是我的類中繼承RKObjectLoaderDelegate的方法。 我正在使用共享的單身人士。

[[RKObjectManager sharedManager] postObject:review usingBlock:^(RKObjectLoader *loader){  
//  loader.params=params, 
     loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[myclass class]]; 
     loader.serializationMIMEType = RKMIMETypeJSON; // We want to send this request as JSON 
     loader.method = RKRequestMethodPOST; 
     loader.serializationMapping = [RKObjectMapping serializationMappingUsingBlock:^(RKObjectMapping* mapping) { 
      [mapping mapAttributes:@"field1", @"field2",@"field3",nil];    
     }]; 
     loader.targetObject = nil; 
     loader.delegate = self; 
    }];  
} 
+0

我想你需要發佈代碼片段和完整的錯誤信息才能在這裏獲得更多的幫助。 – Deepesh

+0

他的問題不需要代碼片段。它詢問如何找到它是什麼對象。 –

回答

0

要設置self爲您的代理(loader.delegate = self;),但它似乎你不執行委託方法objectLoader:didFailWithError:和/或不申報,你符合委託協議RKObjectLoaderDelegate
– objectLoader:didFailWithError: required method是在委託中實現的必需方法。

+0

我確實繼承了RKObjectLoaderDelegate和ovveride objectLoader:didFailWithError。 – user1302602

0

您正在收到消息didFailWithError:並且您的班級無法識別它。你在班上實施了這種方法嗎?至於didFailWithError:未被調用,這是因爲你沒有實現,或者你沒有在正確的類上實現。

0

如果您在RestKit來源看,在文件RKObjectLoader.m,你會看到didFailWithError message有這個代碼:

if (!self.isCancelled) 
    { 
     [self informDelegateOfError:error]; 
    } 

當我得到超時錯誤,它就會以這個if語句和isCancelled設爲YES,所以它跳過代碼來通知代表。這似乎是RestKit代碼中的一個錯誤。此代碼與我以前使用的RestKit版本非常不同。我不知道爲什麼isCancelledboolean設置爲YES,但是如果您註釋掉if語句,它將按照預期將錯誤傳遞給委託。