0

我正在尝试制作一个小 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 设备,还是我完全错误的假设?

4

1 回答 1

0

不,你需要UIPasteboardiOS,NSPasteboard是 OSX。如果您已经下载了 iOS SDK UIKit.framework,可以在以下位置找到:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks

记得更改路径中的 SDK 版本。

于 2013-09-24T10:00:50.157 回答