Created
April 12, 2016 09:34
-
-
Save touyou/878044febdb8eeda0f5d0db967f7e059 to your computer and use it in GitHub Desktop.
NSDataがGIFかどうか判断するためのExtensionのSwift版。Objc-Cで書かれた https://gist.github.com/cathandnya/7279009 を参考にしました。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSData { | |
func isGIF() -> Bool { | |
let bytes = UnsafePointer<Int8>(self.bytes) | |
return self.length >= 6 && (strncmp(bytes, "GIF87a", 6) == 0 || strncmp(bytes, "GIF89a", 6) == 0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment