Objective c NSPNGFileType-在Swift中未找到?
今天,我发现了一些奇怪的事情: 我想用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) 问题是编译器说:“使用未解
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,但没有成功;