-3

Scenario: A cocoaPod (or any shared code/framework) has a deprecated function (in my case MD5 hash) from which I want to display a warning & solution: SHA256().

I only have access to a shared POD. I want future users to be notified that their current API (MD5) has been deprecated and hence, should use a newer API (SHA256).

How do I notify user that the following 'doOldStuff(x: Sting)' is Deprecated, an to use 'doNewStuff(x:String) instead?

enter image description here

I would like to display a compiler WARNING.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105

1 Answers1

3

Swift

Use @available like this.

@available(*, deprecated, message: "Use doNewStuff(x:) instead")
func doOldStuff(x: String) { }

Objective-C

-(void)doOldStuffWithX:(NSString *)x __attribute__((deprecated("Use doNewStuffWithX: instead")));
Tarun Tyagi
  • 9,364
  • 2
  • 17
  • 30