Search code examples
objective-ccsvrownsfilehandle

NSFilehandle and replace a line


I have a comment about how I should handle a csv file in my application.

CSV file will be saved as comma separated, eg customer1, telephone1, mail1, / n customer2, telephone2, mail2, / n and so on I have succeeded. I have also succeeded with the function of the app to delete ENTIRE list (csv) file. But how do I for example just want to delete a row in the csv file? Is it possible?


Solution

  • You will need to read the file in, modify the data / string that has been created from the file and then write the data / string out to replace the original file.

    NSFileHandle can add new data into a file but it can't delete arbitrary data from a file (it can only delete a specified number of bytes from the end of a file).