C-Viorel C-Viorel - 1 year ago 99
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 !

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download