# 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 seem 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 aNSString, 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.