gpt4 book ai didi

ios - RestKit:使用 [[RKClient sharedClient] post: usingBlock:] 时的每个请求对象映射

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:46 26 4
gpt4 key购买 nike

我需要在后台将视频发布到服务器。到目前为止,我在发布时一直使用这种模式:

- (BOOL)loginUser:(user *)user
{
BOOL ret = NO;

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.waitView startWithMessage:@"Signing in ..."];

[self.objectManager postObject:user usingBlock:^(RKObjectLoader *loader)
{
loader.delegate = self;
loader.targetObject = nil;

loader.objectMapping = [RKObjectMapping mappingForClass:[user class] usingBlock:^(RKObjectMapping *mapping)
{
[mapping mapKeyPath:@"id" toAttribute:@"ID"];
[mapping mapKeyPath:@"last_name" toAttribute:@"last_name"];
[mapping mapKeyPath:@"first_name" toAttribute:@"first_name"];
[mapping mapKeyPath:@"middle_name" toAttribute:@"middle_name"];
[mapping mapKeyPath:@"email" toAttribute:@"email"];
[mapping mapKeyPath:@"password" toAttribute:@"password"];
[mapping mapKeyPath:@"authentication_token" toAttribute:@"authentication_token"];
}];

loader.serializationMapping = [loader.objectMapping inverseMapping];
loader.serializationMapping.rootKeyPath = NSStringFromClass([user class]);
}];

return ret;
}

...但是这种模式似乎不允许我访问任何要在其上设置 backgroundPolicy 的 RKRequest 对象。所以,我研究过像这样使用 RKClient:

- (BOOL)postBigMediaFile:(NSString *)pathToBigFile
{
BOOL ret = NO;

NSString *resourcePath = @"/bigFile";

[[RKClient sharedClient] post:resourcePath usingBlock:^(RKRequest *request)
{
request.backgroundPolicy = RKRequestBackgroundPolicyContinue;

// how do I set up the object mapping?


}];

return ret;
}

...但是 RKRequest 对象似乎无法访问要为其设置映射的 RKObjectLoader。如何使用对象映射在后台发布数据?

最佳答案

傻我... RKObjectLoader 是 RKRequest 的子类,所以我可以只做 loader.backgroundPolicy = ... :-)

关于ios - RestKit:使用 [[RKClient sharedClient] post: usingBlock:] 时的每个请求对象映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11750362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com