Question

I have images in uitableview, they each have a string for they're path in documents directory. Now my trouble is if somebody adds the same image they will have the same path. I was thinking of making an if-statement that will run on all of my fetchedResultsController objects or better yet my entire documents directory and append a number or something to the pathString. lets say user adds title.jpg to doc directory, then he adds the same image then I want a check to see if it already exists, if it already exists in doc directory then append title(1).jpg so it can save properly and so on.

any efficient way of doing that ?

Was it helpful?

Solution

Depending on the OS you're targeting you can set the image name using NSUUID. If you're targeting < iOS 6 you'll have to use CFUUIDRef. This will always ensure you have a unique filename for an image.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top