         initNav()
         collectionView?.reloadData()
     }
+ 
     
     func rightItemTapped() {
-        var thumb:[UIImage]? = []
         if seletedPhotosArray.count > 0 {
             for index in seletedPhotosArray {
-                thumb!.append(compress(photosArray[index]!)!)
+                
+                if photosArray[index] == nil {
+                    
+                }
+                else{
+                   thumb!.append(compress(photosArray[index]!)!)
+                }
+                
             }
             delegate?.selected(thumb, src: nil, seletedIndex: seletedPhotosArray)
         }

    var theLastIndexPath:NSIndexPath?
    
    let preloadNum = 300
    
    deinit {
    

    
    var photosAsset:PHFetchResult?
    
    lazy var photosArray:[NSData?] = {
        let photosArray:[NSData?] = []
        return photosArray
    }()
    
    var seletedPhotosArray:[Int] = []
    
