Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Assignment to a property of type NSTextField

I have a little program with one button and a text-field. When clicking the button, it should write a text into the text field. My AppDelegate.h is:

#import <Cocoa/Cocoa.h>

@interface ao_AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;

- (IBAction)DoIt:(id)sender;

@property (weak) IBOutlet NSTextField *MiinText;

@end


and now I would like to fill in in the event routine DoIt of the button a text to property MiinText. I have tried several version (I am brand new in objective-C) and all produce error(s) - see below the Eventroutine in AppDelegate.m


- (IBAction)DoIt:(id)sender {

MiinText = [NSTextField @"jaja"];

}


What is the correct way of performing this assignment. I could not find the answer in the help system. Thanks.

Posted on Jul 11, 2014 7:31 AM

Reply
Question marked as Best reply

Posted on Jul 11, 2014 7:48 AM

[[self MiinText] setStringValue: @"jaja"]


Note instance variables (such as the TextField in your code MiinText) are by convention named starting with a lower case letter; miinText in this example. The same for method names, start with a lowercase letter doIt: rather then DoIt:

1 reply

Assignment to a property of type NSTextField

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.