cocoafan
cocoafan

Reputation: 4894

Best way to post NSNotification with NSRect info?

what is the best way to post a notification with NSRect info?

Here is my current solution (using NSStringFromRect).

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

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

However, I'm not sure if this is the best way to send a rect struct.

Upvotes: 2

Views: 906

Answers (1)

Matt Ball
Matt Ball

Reputation: 6618

You should be using an NSValue created using the +valueWithRect: class method.

Upvotes: 6

Related Questions