gpt4 book ai didi

ios - 如果我同时调用 [[RKClient sharedClient] get @"foo.xml"delegate :self] in two UIViewControllers? 会发生什么

转载 作者:行者123 更新时间:2023-11-29 04:54:54 26 4
gpt4 key购买 nike

如果我在两个 UIViewController 中同时调用 [[RKClient sharedClient] get@"foo.xml"delegate:self] 会怎样?我有什么问题吗?

viewController_A
{
[[RKClient sharedClient] get:@"foo.xml" delegate:self];
}

viewController_B
{
[[RKClient sharedClient] get:@"foo.xml" delegate:self];
}

最佳答案

如果您查看 get:delegate: 的 RKClient 实现,它只是执行此操作

- (RKRequest *)get:(NSString *)resourcePath delegate:(id)delegate {
return [self load:resourcePath method:RKRequestMethodGET params:nil delegate:delegate];
}

并且 load:method:params:delegate: 的实现是

- (RKRequest *)load:(NSString *)resourcePath method:(RKRequestMethod)method params:(NSObject<RKRequestSerializable> *)params delegate:(id)delegate {
NSURL* resourcePathURL = nil;
if (method == RKRequestMethodGET) {
resourcePathURL = [self URLForResourcePath:resourcePath queryParams:(NSDictionary*)params];
} else {
resourcePathURL = [self URLForResourcePath:resourcePath];
}
RKRequest *request = [[RKRequest alloc] initWithURL:resourcePathURL delegate:delegate];
[self setupRequest:request];
[request autorelease];
request.method = method;
if (method != RKRequestMethodGET) {
request.params = params;
}

[request send];

return request;
}

它不使用任何 RKClient 状态/共享数据,因此您不会看到问题。 get:delegate: 方法本身是异步的,所以这些事情无论如何都会在后台发生。

关于ios - 如果我同时调用 [[RKClient sharedClient] get @"foo.xml"delegate :self] in two UIViewControllers? 会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8193089/

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