afnetworking - startMonitoringNetworkReachability 中的 exc_bad_access

发布于 2025-01-07 06:40:24 字数 840 浏览 5 评论 0原文

对于一个项目,我必须使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悸初 2025-01-14 06:40:24

如果你的 baseURL 为零,它就会崩溃。

It will crash if your baseURL is nil.

孤独岁月 2025-01-14 06:40:24

根据文档

此方法需要 SystemConfiguration 框架。将其添加到活动目标的“Link Binary With Library”构建阶段,并将 #import 添加到项目的标头前缀 (Prefix.pch)。

您包含了框架,但是您是否在项目中的某个位置添加了 #import

As per the documentation:

This method requires the SystemConfiguration framework. Add it in the active target’s “Link Binary With Library” build phase, and add #import to the header prefix of the project (Prefix.pch).

You included the framework, but did you add #import <SystemConfiguration/SystemConfiguration.h> somewhere in the project?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文