使用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结构的最佳方法。

最佳答案

您应该使用使用+valueWithRect:类方法创建的NSValue

关于cocoa - 用NSRect信息发布NSNotification的最佳方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/876795/

10-11 22:09
查看更多