Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import Foundation
  2.  
  3. class RNAsyncStorage {
  4. private static let RCTStorageDirectory = "RCTAsyncLocalStorage_V1"
  5.  
  6. private static let RCTManifestFileName = "manifest.json"
  7.  
  8. private static func getStorageDirectory() -> URL? {
  9. return FileManager.default
  10. .urls(
  11. for: .documentDirectory,
  12. in: .userDomainMask
  13. )
  14. .first?
  15. .appendingPathComponent(RCTStorageDirectory)
  16. }
  17.  
  18. private static func getManifestFilePath() -> URL? {
  19. return getStorageDirectory()?.appendingPathComponent(RCTManifestFileName)
  20. }
  21.  
  22. static func getString() -> String? {
  23. guard
  24. let manifestFilePath = getManifestFilePath(),
  25. let result = try? String(contentsOf: manifestFilePath, encoding: .utf8)
  26. else {
  27. return nil
  28. }
  29.  
  30. return result
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement