Joseph
Joseph

Reputation: 9351

adding comment to deprecated method

I have a couple of methods that I want to deprecate.

I do this with the following:

+(void)myMethod:(NSString*)abc __deprecated;

This works, but how do I add a message? Something like "use methody xyz instead"...

Thanks

Upvotes: 7

Views: 3167

Answers (4)

Joseph
Joseph

Reputation: 9351

As Nicholas Smith mentioned in the comments. The solution is:

__attribute((deprecated("use x method")))

if you want you can also use the less convoluted:

__deprecated_msg("use x method")

Upvotes: 13

Mojtaba Hosseini
Mojtaba Hosseini

Reputation: 119380

- FOR SWIFT CODE:

Put this right above the method: @available(*, deprecated: <#Version#>, message: <#Message#>)

example:

@available(*, deprecated: 11, message: "Use color assets instead")
public struct ColorPaletteItemResource: ColorPaletteItemResourceType {
    ...
}

Upvotes: 1

MrJre
MrJre

Reputation: 7161

I would tend to use this:

__deprecated_msg("use method x instead")

rather than:

__attribute((deprecated("use method x instead")))

They're really the same under the hood, but first one is a bit more clear.

Upvotes: 5

Vincent Saluzzo
Vincent Saluzzo

Reputation: 1377

I think you need to use a documentation generator: Doxygen, Headerdoc, etc.

I recommend you Appledoc. It is easy to use, very well documented and markdown style enabled.

Upvotes: 0

Related Questions