I am using FileManager in Ios to create dir and save my log files in it.. When I get String data that I what I am appending it to the file that I have in FileManager dir .. Can i know How much data that I can append and also What happens If it that file has more data then it's limit .. Please help me out.. Is there any way to know my Iphone storage limit while using filemanager?
Asked
Active
Viewed 187 times
-1
-
It is only limited by the device's free space – Leo Dabus Mar 28 '18 at 21:58
-
Is there any way to check device free space ..? so that i will clear log file and create new one. – tp2376 Mar 29 '18 at 13:12
1 Answers
0
There is no real limit for file sizes. You can write to the file system until all storage space is used up. You can append a string to a file with:
FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
let fileHandle = FileHandle(forWritingAtPath: filePath)!
let string = "test"
let data = string.data(using: .utf8)!
fileHandle.seekToEndOfFile()
fileHandle.write(data)
fileHandle.closeFile()

sundance
- 2,930
- 1
- 20
- 25
-
thanks sundance , But i am doing that right know and i am sharing files through activitycontroller .. when I select that it will get the selected file contents but sometimes it is giving me error. – tp2376 Mar 29 '18 at 13:09
-
I figure it our I have to using different encodings.. if file fail to read I am using ascii encoding to read that file .. Now everything is working fine. – tp2376 Apr 15 '18 at 16:17