0

I have an object with an attribute in my xcdatamodel that has validation around it (it must be between 0 and 100).

However, when a value is entered with a value out of range it causes the app to crash when I try to save the object.

Having come from a web development background, I would have expected a DB rollback w/ error message.

Is a crash normal procedure and is there a way to change this beside checking every value before a save?

Gerard
  • 4,818
  • 5
  • 51
  • 80
  • I am surprised that you get a crash - I would expect you to get errors (and a chance to roll-back) instead from my reading of the documentation (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdValidation.html). The docs also indicate that you can run a Property-Level Validation during data entry which would seem to be the way to go (example code in the docs). Unfortunately, I've never used Validation and so have no example code to supply. – Robotic Cat Mar 25 '14 at 17:08

1 Answers1

0

There is no DB as such when writing an iOS App from scratch. You have several options on how to store your data - one of them being Core Data, which has a SQL backend to it.

Error handling is something you have to do yourself, too. If you're only expecting values from 0 to 100 you need to handle values out side of that range too.

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99