我的实体用户有一个 objectMapping
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[User class]];
[userMapping mapKeyPath:@"first_name" toAttribute:@"firstName"];
[userMapping mapKeyPath:@"last_name" toAttribute:@"lastName"];
[manager.mappingProvider setMapping:userMapping forKeyPath:@"users"];
[manager.mappingProvider setSerializationMapping:[userMapping inverseMapping] forClass:[User class]];
我想在应用程序进入后台时保存他的个人资料:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[RKObjectManager sharedManager] putObject:currentUser delegate:self];
}
但它不会让我在关闭应用程序时运行请求(我猜不允许新线程)。所以我想同步地做这个。
但是,我没能用 RestKit 做到这一点。我这边是不是有什么误会?我想拥有:
[[RKObjectManager sharedManager] putObjectSynchronously:currentUser];