简体   繁体   中英

Remove Unused Methods from xcode ios

I am using xcode 9 with objective c. And i want to remove unused variable and methods from classes. I am also use this way but xcode do not warning of unused methods etc. How to find out? 在此输入图像描述

Unfortunately unlike C functions, getting a list of unused objc methods in the form of warnings in Xcode is tricky due to the dynamic runtime environment. Your code might, for example,create a selector from a string and then call that selector on a class or instance of one etc.

One approach I've used, however it's time consuming depending on the size of the class(es), is to open the assistant editor and position the cursor over the method you wish to inspect and select callers (see below image. Normally the default selection is counterparts).

在此输入图像描述

If there are no callers of the method then the editor shows no results.

在此输入图像描述

However if you do this be aware no results will also show for IBActions and overrides in subclasses of iOS frameworks etc. You need to really know the code to determine if 'no results' really means no callers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM