afnetworking - startMonitoringNetworkReachability 中的 exc_bad_access
对于一个项目,我必须使用 AFNetworking。从 github 获取了新的副本,iOS 示例项目似乎正在运行。
但是 - 当我将“AFNetworking”文件夹复制到新的 Xcode 项目并尝试进行 http 调用时,它在 AFHTTPClient 的初始化程序中崩溃
所以在 [AFHTTPClient initWithBaseURL:] 中有这样的代码:
#ifdef _SYSTEMCONFIGURATION_H
[self startMonitoringNetworkReachability];
#endif
它看起来真的很愚蠢但是
1) WHEN我不链接 SystemConfiguration - 该项目无法编译
(架构 i386 的未定义符号: “_SCNetworkReachabilityCreateWithName”,引用自: -AFHTTPClient.o 中的[AFHTTPClient startMonitoringNetworkReachability]
2) 当我链接 SystemConfiguration 时 - 项目在运行时在 startMonitoringNetworkReachability 内崩溃并带有 EXC_BAD_ACCESS:
SCNetworkReachabilitySetCallback(self.networkReachability, AFReachabilityCallback, &context);
有人遇到此问题吗?从他们在 github 上称赞他们的库的方式来看,我认为它会更加精致。
For a project I have to use AFNetworking. Got fresh copy from github and the iOS example project seems to be working.
However - when I copy over the "AFNetworking" folder to a new Xcode project and try to make a http call, it crashes in the AFHTTPClient's initializer
So in [AFHTTPClient initWithBaseURL:] there's this code:
#ifdef _SYSTEMCONFIGURATION_H
[self startMonitoringNetworkReachability];
#endif
and it looks really stupid but
1) WHEN I don't link SystemConfiguration - the project doesn't compile
(Undefined symbols for architecture i386:
"_SCNetworkReachabilityCreateWithName", referenced from:
-[AFHTTPClient startMonitoringNetworkReachability] in AFHTTPClient.o)
2) WHEN I do link SystemConfiguration - the project crashes at runtime inside startMonitoringNetworkReachability with EXC_BAD_ACCESS:
SCNetworkReachabilitySetCallback(self.networkReachability, AFReachabilityCallback, &context);
Did anybody have this problem? From the way they praise their lib on github I thought it'd be more polished.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你的 baseURL 为零,它就会崩溃。
It will crash if your baseURL is nil.
根据文档:
您包含了框架,但是您是否在项目中的某个位置添加了
#import
?As per the documentation:
You included the framework, but did you add
#import <SystemConfiguration/SystemConfiguration.h>
somewhere in the project?