タグ

2016年4月18日のブックマーク (1件)

  • Objective-C で通知の解放忘れとかもろもろを解決するデザインパターン | Covelline Developer Blog

    こんにちわ、 20%ルールの時間を使って30分で書きます。 Objective-C の Notification って便利ですよね。 しかし、色々な問題点を抱えています。 下のサンプルコードを例に説明します。 // 通知を受け取るオブザーバーを登録 - (instancetype)init { self = [super init]; if (self) { NSNotificationCenter *c = NSNotificationCenter.defaultCenter; [c addObserver:self selector:@selector(safe_didChangeHogehoge:) name:kHogeNotificator_safe_DidChangeHogeHogeNotification object:nil]; [c addObserver:self sel

    xhoge
    xhoge 2016/04/18
    “セレクタの名前を変えた時に addObserver のセレクタ名を変更し忘れてクラッシュ NSNotification オブジェクトの userInfo の中身がなんなのか分からない dealloc 忘れてないかとか頑張ってチェックするしかない”