2014-01-28 40 views
-1

嗨。我導入了reachability.h文件和reachability.m文件,以檢查我的應用程序中的Internet連接,但出現ARC錯誤。iOS中的可達性類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

http://stackoverflow.com/questions/12620271/reachability-h-reachability-m-gives-an-apple-mach-o-linker-error-同時添加 – 2014-01-28 09:08:59

+0

刪除屬於內存版本的代碼行。 –

+0

http://stackoverflow.com/a/11945045/1142743 – Vinodh

回答

6

添加類停止電弧您使用的模式

enter image description here

+0

它是'-fno-objc-arc' ! – Bhavin

+0

但得到這樣的警告警告:沒有規則來處理文件如何解決這一個@iDev – user3230582

0

我建議您閱讀有關過渡到ARC的Apple文檔:Transition to ARC

正如您將基於當前指向特定對象的有多少強指針,您將在內存中自動學習dealloc對象。當沒有強對象的強指針(零)時,ARC將立即釋放該對象。因此,所有對象都使用ARC進行自動釋放,因此不會再使用自動釋放。

你可以調用dealloc(儘管除非嚴格必要,否則我不會這樣做)來運行一些在ARC之前被釋放的對象。然而,在dealloc方法中,您不會調用超類方法(我認爲這是與dealloc相關的錯誤的原因),因爲這完全由ARC處理,這一點非常重要。我希望這有幫助。

0

添加-fno-objc-arc標誌您想對您要啓用ARC,爲ARC文檔中描述的任何文件。

1

我想你使用的是舊版本的代碼。請參閱蘋果示例代碼Reachability,該代碼已更新爲使用ARC。

希望有幫助!

0

可達性文件舊版本。您可以下載兼容iOS 6.0及更高版本的最新版本的Reachability文件。

對於舊版本的可達性文件,你可以添加一些標誌,以使ARC

  1. 打開目標項目的
  2. 選擇構建階段
  3. 打開編譯源代碼標籤
  4. 雙擊旁邊的可達性文件
  5. 添加-fno-objc-arc標誌

Screenshot for above steps