我正在尝试制作一个小 dll,以便可以从我的 Unity 应用程序中读取粘贴板。
我有以下代码:
#define MakeStringCopy( _x_ ) ( _x_ != NULL && [_x_ isKindOfClass:[NSString class]] ) ? strdup( [_x_ UTF8String] ) : NULL
#define GetStringParam( _x_ ) ( _x_ != NULL ) ? [NSString stringWithUTF8String:_x_] : [NSString stringWithUTF8String:""]
//[UIPasteboard generalPasteboard].string = @"the text to copy";
//NSString *whatsOnThePasteboard = [UIPasteboard generalPasteboard].string;
//send clipboard to unity
extern "C" const char * _importString()
{
NSString *result = [UIPasteboard generalPasteboard].string;
return MakeStringCopy(result);
}
//get clipboard from unity
extern "C" void _exportString(const char * eString)
{
[UIPasteboard generalPasteboard].string = GetStringParam(eString);//@"the text to copy";
}
但是,关于 UIPasteboard,我有以下错误
使用未声明的标识“UIPasteboard”;你的意思是“NSPasteboard”吗?
我查看了所需的框架,但看不到 UIKit.framework 将其添加到我的包中。所以我的问题是:
如果我将其更改为 NSPasteboard,它是否仍能按预期在我的 iPad 上运行?从我读到的 UIpasteboard 是用于 iOS 设备而 NSPasteboard 是用于 OSX 设备,还是我完全错误的假设?