On Tue, Dec 9, 2008 at 11:17 AM, Chunk 1978 <[EMAIL PROTECTED]> wrote: > that works... but now i want that rect to redraw itself when notified > to do so, but i can't figure out how to notify the NSRect to draw > again... all my NSUserDefaults colorAsData is in place, as well as my > NSNotifications. it will print to NSLog so i know that notification > is being called, but how do direct that notification to the drawRect > method?
In addition to NIck's advice, you should give this a thorough read (to save yourself lots of headaches): http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/chapter_1_section_1.html Also, the custom view that draws the rectangle should probably maintain this property itself (such as -rectColor). It's probably trivial for your current application (which looks like a learning exercise) but has performance implications in a full-fledged app. This way, you can always use [self rectColor] instead of all the messaging overhead of asking preferences each time you draw. To handle the color change in the user defaults, use the same method (the notification) but set the new color as the notification's object when you post the notification in the first place, then your view can ask the notification for its -object and (if it's a proper color), call [self setRectColor:[aNotification object]]. In your -setRectColor: you can store the color then immediately call [self setNeedsDisplay:YES] (if the color is different). This way, any time the view's color is set (either directly or by notification), the view is always marked as needing display and no further calls to -setNeedsDisplay: are needed for rect color changes. That means less to debug. :-) -- I.S. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]