我正在查看 NSURLProtocol 并尝试插入一些 header 。
- (void)startLoading {
NSMutableURLRequest *newRequest = [self.request mutableCopy];
[NSURLProtocol setProperty:@YES forKey:kAccessCodeProtocolKey inRequest:newRequest];
self.connection = [NSURLConnection connectionWithRequest:self.request delegate:self];
}
但我的 startLoading 从未被调用
最佳答案
你实现了 canInitWithRequest: 了吗?它返回 YES 吗?否则,将永远不会调用 startLoading。
关于ios - 为什么不在我的 NSURLProtocol 子类中调用 startLoading?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22388034/