I'm trying to learn ObjC/Cocoa...but it's working against me.
I created this class:
The textInput is connected to a NSTextField, the textOutput is connected to a NSTextView, and sender is connected to a button. Here is the sender code:
I want it to append string to the text view, but it's not working. I also tried this and failed.
I created this class:
Code:
#import <Cocoa/Cocoa.h>
@interface TestObject : NSObject {
IBOutlet id textInput;
IBOutlet id textOutput;
}
- (IBAction)sender:(id)sender;
@end
The textInput is connected to a NSTextField, the textOutput is connected to a NSTextView, and sender is connected to a button. Here is the sender code:
Code:
#import "TestObject.h"
@implementation TestObject
- (IBAction)sender:(id)sender {
NSString *text = [textInput stringValue];
[textOutput setStringValue: text];
}
@end
I want it to append string to the text view, but it's not working. I also tried this and failed.
Code:
NSTextStorage *storage = [textInput textStorage];
[storage beginEditing];
[storage appendAttributedString:text];
[storage endEditing];