C-Viorel C-Viorel - 18 days ago 5
Swift Question

NSPNGFileType - not found in Swift?

Today, I found something strange :

I wanted to write this code in swift :

NSData *data = [myImage representationUsingType: NSPNGFileType properties: nil];

In swift it's look like this:

var data: NSData = imageToSave?.representationUsingType( NSPNGFileType ,
properties: nil)

The problem is that the compiler say : " Use of unresolved identifier 'NSPNGFileType'".
Does anyone have any idea why ?

Thanks, and sorry for my english !


You probably have to use .NSPNGFileType, or more explicitly NSBitmapImageFileType.NSPNGFileType