質問

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?

役に立ちましたか?

解決

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).

他のヒント

NSFileHandle does not provide any api for deleting the lines in a file. But you can take the mutablestring and then whatever lines you want to append on that use appendstring api of mutable string which allows you to perform same action and also put your condition which lines you does not want to append. Once its done rewrite the csv file which will replace the old csv file.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top