Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark a method as deprecated

Tags:

xcode

ios

api

I have a change in my API and I want to mark one method as deprecated. I've put the following on it's signature: attribute((deprecated("Don't use this method"))); However, I don't know how do I need to behave in the method body itself.

Can't find anything on Apple coding starts to lead me. The method return BOOL. should I just return false?

like image 287
Gal Marom Avatar asked Jun 30 '14 14:06

Gal Marom


1 Answers

Deprecated means the method still work, but can be removed in the future versions and the new method is most preferred.

You can give some additional info to the user who uses the deprecated method:

/**
 * @deprecated This method is deprecated starting in version x.x
 * @note Please use @code newMethod:withNewParameter: @endcode instead.
 */
-(void)depFunction:(id)x __attribute__((deprecated));

When he use like:

[yourClassObj depFunction:@"argument"];

The Quick Help Panel will show an information like:

Deprecated

You might also want to change attribute((deprecated("Don't use this method"))); to DEPRECATED_MSG_ATTRIBUTE("Don't use this method, use the other one instead.");

like image 199
Midhun MP Avatar answered Oct 12 '22 07:10

Midhun MP