2

NSRect 情報を含む通知を投稿する最良の方法は何ですか?

これが私の現在のソリューションです(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 構造体を送信する最良の方法であるかどうかはわかりません。

4

1 に答える 1

6

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

于 2009-05-18T09:05:11.567 に答える