Guest User

Untitled

a guest
Nov 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. if let newImage = aImage {
  2.  
  3. let date = HelpherMethod.sharedInstance().toLocalTime(Date())
  4. let resource = PHAssetResource.assetResources(for: phAsset!).first
  5. let fileName = resource?.originalFilename
  6. var imageName : String?
  7. let timestamp = date?.timeIntervalSince1970
  8. print(String(format:"%.0f",timestamp!))
  9. let currentTimeStamp = String(format:"%.0f",timestamp!)
  10. imageName = String(format:"%@_%@",AuthService.instance.userName,currentTimeStamp)
  11.  
  12. let mImage = self.objectWithTypePredicate(aType: "Image", predicate: NSPredicate(format:"(imageName == %@)",imageName!), canCreate: true)
  13.  
  14. mImage?.setValue(fileName, forKey: "fileName")
  15. mImage?.setValue(date, forKey: "dateTime")
  16. mImage?.setValue(objectId, forKey: "objectId")
  17. mImage?.setValue(objectType, forKey: "objectType")
  18. mImage?.setValue(objectName, forKey: "objectName")
  19. mImage?.setValue(newImage, forKey: "image")
  20. mImage?.setValue(imageName, forKey: "imageName")
  21. mImage?.setValue(imageUrl, forKey: "imageUrl")
  22. if let loc = location {
  23. mImage?.setValue(loc, forKey: "location")
  24. }
  25. mImage?.setValue("progress", forKey: "status") //Status failed for not uploaded // progress for processing// success for sync// at the initial level all status are set to progress
  26. do {
  27. try mImage?.managedObjectContext?.save()
  28. } catch {
  29. fatalError("Failure to save context: (error)")
  30. }
  31. }
Add Comment
Please, Sign In to add comment