我无法让此方法返回 YES:
- (BOOL) writeToPasteBoard:(NSString *)stringToWrite
{
return [pasteBoard setString:stringToWrite forType:NSStringPboardType];
}
我已经验证 stringToWrite 正确通过,该方法总是返回 NO。
有任何想法吗?
这是课程的其余部分:
@interface ClipBoard : NSObject {
NSPasteboard *pasteBoard;
}
- (BOOL) writeToPasteBoard:(NSString *)stringToWrite;
- (NSString *) readFromPasteBoard;
@end
@implementation ClipBoard
- (id) init
{
[super init];
pasteBoard = [NSPasteboard generalPasteboard];
return self;
}
- (BOOL) writeToPasteBoard:(NSString *)stringToWrite
{
return [pasteBoard setString:stringToWrite forType:NSStringPboardType];
}
- (NSString *) readFromPasteBoard
{
return [pasteBoard stringForType:NSStringPboardType];
}
@结尾