開始我的RestKit開發,試圖做出第一個請求。從Github拿來這個示例代碼,爲我的課程修改,但在設備上運行後,我沒有看到任何活動的跡象。即沒有回調,沒有崩潰,沒有例外,沒有日誌輸出。我是否認爲它錯了?代碼如下:RestKit 0.20pre2請求後沒有響應
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[FavoritePlace class]];
[mapping addAttributeMappingsFromDictionary:@{@"name": @"name", @"placeId": @"id"}];
NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful); // Anything in 2xx
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping pathPattern:@"/favoritePlace/:placeID" keyPath:@"id" statusCodes:statusCodes];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://my.internal.url/v20"]];
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]];
[operation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
FavoritePlace *place = [result firstObject];
NSLog(@"Mapped the place: %@", place);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failed with error: %@", [error localizedDescription]);
}];
我正在使用https,正如您所看到的那樣 - 是否支持?
作爲獎勵,任何人都可以提供最簡單的0.20 API代碼示例,只是爲了看看這個東西是否可以工作?
謝謝,這可能有所幫助。我已經從Github檢出了整個RestKit項目並試圖構建它。不幸的是,構建失敗,抱怨缺乏AF *類(頭文件未找到)。看起來像缺少一些依賴關係。我試圖在根目錄下運行「pod install」,但是當Cocoapods嘗試獲取「[email protected]:blakewatters/ocmock.git」時,我收到一個我無法驗證的錯誤。我沒有任何Github賬戶,這可能是一個問題嗎?總的來說,我是否正確地在本地構建RestKit? – Haspemulator
如果您的pod安裝失敗(因爲AFNetworking子模塊尚未加載),請隨意使用包含所有外部框架和庫的完整下載軟件包。 https://github.com/RestKit/RestKit/downloads – flashfabrixx