7

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

Joseph
  • 9,171
  • 8
  • 41
  • 67
  • what about adding headerdoc? – V-X Mar 19 '13 at 09:11
  • 3
    http://stackoverflow.com/questions/4924285/how-to-deprecate-a-method-in-xcode according to the 3rd comment on the answer you use `__attribute((deprecated(use x method)))` – Nicholas Smith Mar 19 '13 at 09:12
  • Tried that but I get an error at the space after "use". Xcode says "Expected )" – Joseph Mar 19 '13 at 09:26
  • 1
    My bad, I should have followed up on the answer rather than just linking it, in the clang language extensions guide (http://clang.llvm.org/docs/LanguageExtensions.html#messages-on-deprecated-and-unavailable-attributes) it says the message must be inside `""`. – Nicholas Smith Mar 19 '13 at 11:45
  • It's that simple huh *head:desk* :) make this into an answer so I can approve it. – Joseph Mar 19 '13 at 11:47

4 Answers4

13

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")
Joseph
  • 9,171
  • 8
  • 41
  • 67
5

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.

MrJre
  • 7,082
  • 7
  • 53
  • 66
1

- 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 {
    ...
}
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
0

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.

Vincent Saluzzo
  • 1,377
  • 1
  • 11
  • 13