How i will Read & Write Data in path Swift?

//directory
   let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("fileSave")
   let data: Data!
   //for Read Data
   do{
       data = try Data(contentsOf: path)
   }catch{
       print("\(error)")
   }
   //for Write Data
   do{
       try data.write(to: path)
   }catch{
       print("\(error)")
   }

 

293 thoughts on “How i will Read & Write Data in path Swift?

Leave a Reply

Your email address will not be published. Required fields are marked *