发布带有 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];
}
但是,我不确定这是否是发送矩形结构的最佳方式。
最佳答案
您应该使用 NSValue使用 +valueWithRect:
类方法创建。
关于cocoa - 使用 NSRect 信息发布 NSNotification 的最佳方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/876795/