您好。我导入了reachability.h文件和reachability.m文件,以检查我的应用程序中的互联网连接,但是我收到了ARC错误。
我必须尝试将应用程序转换为ARC,但它仍然显示如下错误:
compile Reachability.m and compile Reachability m files
implicit conversion of objective c pointer type 'Reachability *' to Cpointer type void * requires a bridged cast
ARC forbids explicit message send of 'dealloc'
ARC forbids explicit message send of 'autorelease'
ARC forbids explicit message send of 'autorelease'
'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode
'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode
Cast of C pointer type 'void*' to Objective - C pointer type 'Rachability*' requires a bridged cast
release is unavailable: not available in automatic reference counting mode
ARC forbids explicit message send of 'release
我不知道如何解决这个问题。我需要帮助。
由于
答案 0 :(得分:6)
添加您的课程以停止弧形模式
答案 1 :(得分:1)
根据您是否要按原样使用该课程,您始终可以enable ARC for just a single file,而不是整个项目。
非常方便地包含需要或不需要ARC的第三方来源。
答案 2 :(得分:1)
我认为您使用的是旧版本的代码。请参阅更新为使用ARC的Reachability的Apple示例代码。
希望有所帮助!
答案 3 :(得分:0)
我建议您阅读有关过渡到ARC的Apple文档:Transition to ARC。
您将学习ARC根据当前指向特定对象的强指针数自动释放内存中的对象。如果没有对象的强指针(零),ARC将立即释放该对象。因此,您将不再使用自动释放,因为所有对象都是使用ARC自动释放的。
你可以调用dealloc(虽然我不会这样做,除非是绝对必要的)来运行一些来自ARC的对象之前。然而,在dealloc方法中你不要调用超类方法(我假设它是与dealloc相关的错误的原因)非常重要,因为这将完全由ARC处理。我希望这会有所帮助。
答案 4 :(得分:0)
将<{1}}标记添加到您要为其启用 ARC 的任何文件,如 ARC 文档中所述。
答案 5 :(得分:0)
您使用的可访问性文件是旧版本。您可以下载与iOS 6.0及更高版本兼容的Reachability文件的最新版本。
对于旧版本的Reachability文件,您可以添加一些标志以启用ARC
-fno-objc-arc
标志