オープンデータとプログラミング

Xcode:didReceiveMemoryWarning() メソッドとは?

Xcode

didReceiveMemoryWarning() メソッドは、警告を受け取ったときに呼ばれるメソッドです。

画像ファイルなど、使用している大きなメモリ領域を解放します。

メモリ警告を無視するとアプリが異常終了する場合があります。

iOSシミュレーターにも、メモリ警告のシミュレート機能が備わっているので、テスト時に確認しておくと安心ですね。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import UIKit
 
class ViewController: UIViewController {
 
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
 
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
 
}

didReceiveMemoryWarning() メソッドについては、以下の本に詳しく書かれています。

より詳しく勉強してみたい方は読んでみてはいかがでしょうか。

Comments are closed.