How to compare 2 data from a UIImagePNGRview?

I had it in Swift 2.x

let data1 = UIImagePNGRepresentation(self)!
let data2 = UIImagePNGRepresentation(image)!
return data1.isEqualToData(data2)

But now Xcode 8 - Swift 3 tells me:

Value of type 'Data' has no member 'isEqualToData'

I also tried using data1.isEqual(to: data2), but it hasn’t changed much.

+4
source share
1 answer

This is a Swift, not a C lens. In Swift, if the type conforms to the Equatable protocol (and Data Equatable), you use operator == to compare two instances, not .isEqaul:

return data1 == data2
+8
source

Source: https://habr.com/ru/post/1659118/


All Articles