ios警告:Category is implementing a method which will also be implemented by its primary class 引發的相關處理

來源:互聯網
上載者:User

標籤:

今天在處理項目中相關警告的時候發現了很多問題,包括各種第三方庫中的警告,以及各種亂七八糟的問題  先說說標題中的問題  Category is implementing a method which will also be implemented by its primary class  這個警告的意思是 我在category中重寫了原類的方法 而蘋果的官方文檔中明確表示  我們不應該在category中複寫原類的方法,如果要重寫 請使用繼承  原文是這樣的:A category allows you to add new methods to an existing class. If you want to reimplement a method that already exists in the class, you typically create a subclass instead of a category.  所以這裡就出現了警告,警告而已,畢竟不是錯誤,所以也不會影響我們的使用,但是會讓人看著很不爽,所以查了一下不顯示這個警告的方法

1.在相關位置插入下面這段代碼

#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"// your override#pragma clang diagnostic pop

2.在target的 build settings下  搜尋other warning flags  然後給其添加 -Wno-objc-protocol-method-implementation

好了  警告沒有了

這裡順便說一下  2中的方法  對很多批量的警告很有用  而後面相關欄位 -Wno-objc-protocol-method-implementation  其實是可以查得到的    方法是在xcode中選擇你想屏蔽的警告,右鍵選擇 reveal in log 就可以在警告詳情中發現 -Wobjc-protocol-method-implementation  這麼一個格式的欄位 在-W後添加一個no-  然後在用2中的方法添加到 other warning flags 中 就可以處理大部分的警告了

ios警告:Category is implementing a method which will also be implemented by its primary class 引發的相關處理

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.