2009-05-18 10 views
2

NSRect情報で通知を送信する最善の方法は何ですか?NSRect情報でNSNotificationを投稿する最も良い方法は?

ここに私の現在の解決策(NSStringFromRectを使用)があります。

- (void)postNotificationForDirtyRect:(NSRect)rect 
{ 
    NSDictionary *userInfo = 
     [NSDictionary dictionaryWithObject: NSStringFromRect(rect) 
            forKey: ILDirtyRect]; 

    NSNotificationCenter *ncenter = [NSNotificationCenter defaultCenter]; 
    [ncenter postNotificationName: ILDocumentBecomeDirtyRectNotification 
          object: self 
         userInfo: userInfo]; 
} 

ただし、これがrect構造体を送信する最適な方法かどうかはわかりません。

答えて

6

+valueWithRect:クラスメソッドを使用して作成されたNSValueを使用する必要があります。

+0

優秀!ありがとうございました。 – cocoafan

関連する問題