简体   繁体   中英

Model validation causes iOS app to crash

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM