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.
+1
A:
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.
coneybeare
2010-06-05 15:07:45