I have implemented a subclassed version of NSTextField
, which I've called CustomTextField
, the code for which is below:
@interface CustomTextField : NSTextField
@property (nonatomic, strong) IBInspectable NSImage *backgroundImage;
@end
@implementation CustomTextField
- (void)awakeFromNib
{
[self setDrawsBackground:NO];
}
- (void)drawRect:(NSRect)rect
{
NSImage *backgroundImage = self.backgroundImage;
[backgroundImage drawInRect:rect fromRect:rect operation:NSCompositeSourceOver fraction:1.0];
[super drawRect:rect];
}
@end
I have three instances of this custom text field, which I've set-up in my XIB file. When I run the app, select a text field, type in some text, and hit 'Enter', I get the following output from Xcode:
malloc: protecting edges
malloc: enabling scribbling to detect mods to free blocks
malloc: nano zone does not support guard pages
malloc: purgeable zone does not support guard pages
My guess is that my subclass implementation is not handling something correctly, but I'm honestly not sure. Does anyone have some suggestions? Thanks!