开发者

Deleting a line from a txt file in objective-c

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜