iphoneobjective-cipadcore-data

CoreDataBooks Example Saving Conditions


I have based a large portion of CoreData functionality n my app on the CoreDataBooks example by Apple. There is a specific attribute, for me the 'name', that must be filled in before saving is possible.

How can I alter the code to only allow saving under certain circumstances? Such as only saveable when that name field is not empty?


Solution

  • Yes, there is an "optional" option for your entity attribute. First select the attribute then in the side bar un-check optional, see image below. Also there is a validation option where you can define: min. and max. lengths, and default values.

    enter image description here