开发者

Deleting a line from a txt file in objective-c

开发者 https://www.devze.com 2023-01-02 04:30 出处:网络
Is there a way to remove a line from the end of a .txt file from Objective-C? I can\'t s开发者_Python百科eem to find anything on manipulating text files from Objective-C, only reading them into a NSSt

Is there a way to remove a line from the end of a .txt file from Objective-C? I can't s开发者_Python百科eem to find anything on manipulating text files from Objective-C, only reading them into a NSString.


Have you considered changing your data model to a plist? Plists are more easily read/written into/from NSDictionaries.

Otherwise, I think the only way is to read the file into a NSString, separate into a component NSArray by splitting on \n, remove the object at index n, write back into a string by joining with component \n, then writing back to the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消