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 回答