Hello List, Normally variable names don't interfere with method names. So I can write:
CGFloat alphaValue = [ myCustomView alphaValue ]; Now, in an app the -drawRect: method of my custom view was not called although it should. I found out that the culprit was an outlet named "alphaValue" which is also an NSView method. Here is the tracked down example. Xcode 3.2.2, IB 3.2.2, GCC 4.2, Architecture: 10.6 | Debug | x86_64 A new Cocoa App with the following NSView subclass: // MyView.h #import <Cocoa/Cocoa.h> @interface MyView : NSView { IBOutlet NSTextField *alphaValue; } @end // MyView.m #import "MyView.h" @implementation MyView - (id)initWithFrame:(NSRect)frame { NSLog(@"%@", NSStringFromSelector(_cmd)); self = [super initWithFrame:frame]; if (self) { // Initialization code here. } return self; } - (void)drawRect:(NSRect)rect { NSLog(@"%@", NSStringFromSelector(_cmd)); [[ NSColor whiteColor ] set ]; NSRectFill(rect); } @end In IB drop a custom view and assign it to MyView. Then drop a label into the window without connecting it. In Xcode Build & Run -> -drawRect: method is called and a white rectangle is shown. Now connect in IB the label with the outlet of MyView and Run again. -> -drawRect: is not invoked, no rectangle is drawn, and no error or warning appeares. Funny, or ? I hope you can reproduce it. I solved the problem by renaming the outlet to "alfaValue". Is it in general better to avoid outlet names that are also method names? Best Jochen Moeller_______________________________________________ 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 arch...@mail-archive.com