开始我的 RestKit 开发,尝试提出第一个请求。从 Github 获取此示例代码,针对我的课程进行了修改,但在设备上运行后,我没有看到任何活动迹象。即没有回调,没有崩溃,没有异常,没有日志输出。我拿错了吗?这是代码:
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 的最简单的代码示例,只是为了看看这个东西是否有效?