I am new to swift.
I have one code. It encode a local image logo.png to NSData.
let testImage = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("logo", ofType: "png")!)
How to encode an image from a URL to NSData?
Replace myURL with the required URL:
let testImage = NSData(contentsOfURL: myURL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With