             delayObject = unsafeBitCast(CFDictionaryGetValue(gifProperties,
                 unsafeAddressOf(kCGImagePropertyGIFDelayTime)), AnyObject.self)
         }
-
+        
         delay = delayObject as! Double
-
+        
         if delay < 0.1 {
             delay = 0.1 // Make sure they're not too fast
         }
-
-
+        
         return delay
     }
-
+    
     class func gcdForPair(var a: Int?, var _ b: Int?) -> Int {
         // Check if one of them is nil
         if b == nil || a == nil {

import ImageIO

extension UIImage {

    public class func animatedImageWithData(data: NSData) -> UIImage? {
        guard let source = CGImageSourceCreateWithData(data, nil) else { return nil }

        return UIImage.animatedImageWithSource(source)
    }

    class func delayForImageAtIndex(index: Int, source: CGImageSource!)
        -> Double {
        var delay = 0.1

        // Get dictionaries
        let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil)
        let gifProperties: CFDictionaryRef = unsafeBitCast(

                return 0
            }
        }
        
        // Swap for modulo
        if a < b {
            let c = a
            a = b
            b = c
        }
        
        // Get greatest common divisor
        var rest: Int
        while true {
            rest = a! % b!
            
            if rest == 0 {
                return b! // Found it
            } else {
