1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Swift】メソッドを非推奨にする

Last updated at Posted at 2023-03-01

はじめに

個人開発アプリで機能を更新しました。
今後、以前まで使用していたメソッドに戻す可能性があると思ったので一応メソッド自体は残しています。
しかし、使用はしたくないので非推奨メソッドにしたいです。
やりかたを記録しておきます。

実装

@available(*, deprecated, message: "Use fetchSearchAdaptive()")
func fetchSearchUniversal() {
    // 処理...
}

func fetchSearchAdaptive() {
    // 処理...
}

どのようになるか

以下のように非推奨メソッドを使用すると警告が表示されます
スクリーンショット 2023-03-01 22.12.57.png

おわり

使用していないメソッドを残すこと自体良くない気がします笑
しかし、規模が大きくなると一気にリプレイスできないと思うので、今回の方法は便利だと思いました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?