I have an entity in core data that has 2 Attributes. One that is a string called “name”, and another one that is a string called “message”. I need a method to create text files for all the attributes that the user has added. I wan’t the files names to be the name attribute and the contents to be the message attribute. If anyone knows how to do this any help would be great.
Thanks for any help
Have you given any thought at all to the steps involved?
with a predicate if you want to
filter the results).
Once you’ve identified the steps, it’s not difficult at all to look up the relevant parts of the documentation to figure out how to do each step.
You could actually perform this in three lines of code if you inline some things and have already verified the target folder is writable and don’t care about overwriting.
Update
Okay, so it takes a minimum of four lines since you can’t init a fetch request with an entity description, assuming you ignore fetch errors. Since you asked for the code:
Of course this isn’t very readable (ie, it’s ugly) and makes all sorts of assumptions, but you get the point. Here’s a more complete (and illustratively verbose) way: