                 StartDisplay()
             }
             if(isDiscarded(self)==true){
-                self.animationManager.DeleteImageView(self)
-            }
-        }
-    }
-    
+                self.animationManager?.DeleteImageView(self)
+            }
+        }
+    }
+
     public func isDiscarded(imageView:UIView?) -> Bool{
         if(imageView == nil || imageView!.superview == nil){
             return true
         }
         return false
     }
-    
-    
+
+
     public func isDisplayedInScreen(imageView:UIView?) ->Bool{
         if (self.hidden) {
             return false
         }
         let screenRect = UIScreen.mainScreen().bounds
         let viewRect = imageView!.convertRect(self.frame,toView:UIApplication.sharedApplication().keyWindow)
-        
+
         let intersectionRect = CGRectIntersection(viewRect, screenRect);
         if (CGRectIsEmpty(intersectionRect) || CGRectIsNull(intersectionRect)) {
             return false
         }
         return true
     }
-    
+
     private func updateIndex(){
         self.syncFactor = (self.syncFactor+1)%gifImage.displayRefreshFactor!
         if(self.syncFactor==0){

            objc_setAssociatedObject(self, _syncFactorKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN);
        }
    }
    
    public var loopTime:Int{
        get {
            return (objc_getAssociatedObject(self, _loopTimeKey) as! Int)

            objc_setAssociatedObject(self, _haveCacheKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN);
        }
    }

    public var displaying:Bool{
        get {
            return (objc_getAssociatedObject(self, _displayingKey) as! Bool)
