-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
  • 90,369
  • 161
  • 124
  • 175
Frederick C. Lee
  • 8,358
  • 15
  • 62
  • 97

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
  • 8,556
  • 2
  • 12
  • 27