Visual Studio can tell me the methods that are never called, can XCode do the same? Guess not, since they might be called through selector and the name can be formed on fly.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no true idea of “unused method” in Obj-C. Because everything is invoked via message passing, the compiler may not be able to find any call sites that explicitly invoke that message, and yet it’s still invoked via runtime methods.
If you want to figure out if a method is unused, you can do a project-wide search for the method name (if it takes multiple arguments, you could just try the most distinctive portion of the name, e.g. if you have
-loadData:MIMEType:textEncodingName:baseURL:you could search for justMIMEType:). This will give you a good idea if there’s any explicit calls of this method. If you’re sure you aren’t dynamically constructing method names at runtime, then this may be a method that’s never called. But whether or not you can actually be confident in this depends on how complex your project is and how much runtime “magic” you use.