gpt4 book ai didi

ios - AFNetworking 的 requestWithMethod :path:parameters: Returning NSMutableURLRequest That Doesn't Persist

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

我使用 AFNetworking 版本 0.10.x 来实现 iOS 4.3 兼容性。此版本的 AFNetworking 不使用 arc,因此 AFHTTPClient 以及其他 AFNetworking 类都应用了 fno-objc-arc 标志(我的项目的其余部分正在使用 ARC)。在函数中我有以下代码:

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:url]];
[httpClient setParameterEncoding:AFJSONParameterEncoding];
NSMutableURLRequest *urlRequest = [httpClient requestWithMethod:method
path:nil
parameters:adjustedParameters];
NSLog(@"returning: %@", urlRequest);
return urlRequest;

我看到的问题是 urlRequest 总是返回 NULL。

我什至使用调试器单步调试了这段代码:

picture depicting issue

正如您所看到的,当调试器声明 url 请求指向有效的内存地址时,日志打印出 null 值。我正在 iOS 6.0 上使用 Xcode 4.6.3 运行我的项目。知道问题是什么吗?

最佳答案

问题是 requestWithMethod:path:parameters: 方法返回一个 nil 请求对象,因为我将 nil 作为路径参数传递。我的代码应该是:

urlRequest = [httpClient requestWithMethod:method
path:@""
parameters:adjustedParameters];

关于ios - AFNetworking 的 requestWithMethod :path:parameters: Returning NSMutableURLRequest That Doesn't Persist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19075365/

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