I’m subclassing NSTextField
MultiTextField.h
#import <AppKit/AppKit.h>
@interface MultiTextField : NSTextField {
id storedObject;
}
@property (nonatomic, retain) id storedObject;
@end
MultiTextField.m
#import "MultiTextField.h"
@implementation MultiTextField
@synthesize storedObject;
@end
to store a pointer to an object, which I want to “rename”.
I made this textfield editable and have a delegate which listens to controlTextDidChange: and works fine:
- (void)controlTextDidChange:(NSNotification *)aNotification {
NSTextView *textView = [[aNotification userInfo] objectForKey:@"NSFieldEditor"];
NSString *theString = [[textView textStorage] string];
if([theString length] > 0 ) {
MyObject *theObject = ???; // I need access to the MultiTextField.storedObject!
[theObject setName:theString];
}
}
the only problem is that I can’t access the storedObject (see comment in the if-block).
So how do I access that storedObject?
Try this: