Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c NSPNGFileType-在Swift中未找到?_Objective C_Macos_Swift_Xcode6 - Fatal编程技术网

Objective c NSPNGFileType-在Swift中未找到?

Objective c NSPNGFileType-在Swift中未找到?,objective-c,macos,swift,xcode6,Objective C,Macos,Swift,Xcode6,今天,我发现了一些奇怪的事情: 我想用swift写这段代码: NSData *data = [myImage representationUsingType: NSPNGFileType properties: nil]; 在swift中,它看起来像这样: var data: NSData = imageToSave?.representationUsingType( NSPNGFileType , properties: nil) 问题是编译器说:“使用未解

今天,我发现了一些奇怪的事情:

我想用swift写这段代码:

    NSData *data = [myImage representationUsingType: NSPNGFileType properties: nil];
在swift中,它看起来像这样:

var data: NSData = imageToSave?.representationUsingType( NSPNGFileType ,
            properties: nil)
问题是编译器说:“使用未解析标识符'NSPNGFileType'”。 有人知道为什么吗


谢谢,对不起我的英语

您可能必须使用
.NSPNGFileType
,或者在Swift 3中更明确地使用
NSBitmapImageFileType.NSPNGFileType
这已更改为简单的
.PNG
或作为完整版本
NSBitmapImageFileType.PNG
()。

谢谢。奇怪的事。在这里发布问题之前,我尝试过编写NSBitmapImageFileType,但没有成功;