Yes, you essentially have two options (broadly speaking)
First option, force the user to be online at the time when they want to save changes, and then do an online check to see if the
lock flag is set before saving. (Note you need to do the save before calling
dismiss will also persist changes to view variables.
Second option (used if you need to allow users to make changes offline and decide whether or not those changes should get persisted once they get back online), make the changes to a clone of the original object, save the clone and then have online (Cloudcode or Manual) business logic that determines whether or not the changes on the clone object should be applied/persisted to the original object. Using this method you can essentially implement any custom conflict resolution strategy