0
我試圖修改NSTextView對象的字符串內容。到目前爲止,我已經能夠使它與以下代碼一起工作。在IBAction方法之外更改NSTextView內容
.h文件中
#import "AppDelegate.h"
@interface InterfaceManager : AppDelegate {
IBOutlet NSTextView *content;
}
-(IBAction)displayOutput:(id)sender;
@property (assign) IBOutlet NSWindow *window;
@end
.m文件
#import "InterfaceManager.h"
@implementation InterfaceManager
-(IBAction)displayOutput:(id)sender {
[content setString:@"This is a string"];
}
@end
所有工作完全正常和不正是我想要的東西。
但是我需要能夠在void方法中做同樣的事情。這是我嘗試過的。
.h文件中
#import "AppDelegate.h"
@interface InterfaceManager : AppDelegate {
IBOutlet NSTextView *content;
}
-(void)displayOutput:(NSString *)string;
@property (assign) IBOutlet NSWindow *window;
@end
.m文件
#import "InterfaceManager.h"
@implementation InterfaceManager
-(void)displayOutput:(NSString *)string {
[content setString:string];
}
@end
,它似乎並沒有工作。
我在做什麼錯誤,以及如何修復它使其工作?
在此先感謝! :)