objective c - Core Data + NSTextView + Undo Manager -
objective c - Core Data + NSTextView + Undo Manager -
i'm trying create non-trivial job core info backed nstextview. want store in core info model not whole nstextstorage, instead break paragraphs , persist paragraphs each in individual entity.
in fact got work. can't deal undo/redo support. if store every alter in textdidchange notification or something, lose nstextview's undo support, because core info begins store every single character did entered text storage. so, undo manager registers actions individually. , when undo, undo character-by-character , isn't thing want. if don't store inputted text in core data, textview's undo management works fine.
how can know when undo manager begins , closes grouping of actions, store changes when grouping closed?
i trying observe nsundomanagerdidcloseundogroupnotification of nsundomanager didn't help, because notification during every single character input , still annoying character-by-character undo behavior.
is possible workaround?
update: able accomplish goal disableundoregistration() while i'm updating core info entity. i'm wondering if there's solution.
it seems, it's working. in textstoragedidprocessediting delegate method i'm calculating changes made nstextstorage. , find right paragraph entities in core info model. i'm updating model, before start, i'm disabling managedobjectcontext's undo registration , enable when finished updating model. of textstoragedidprocessediting delegate method. have tested night. didn't found bugs. nstextview's undo manager working expected , model updates according text changes. core info model has not big nsattributtedstring transported property, nsorderedset of entities each of them representing unique paragraph of nstextview (thanks nsuuid)
objective-c cocoa core-data swift
Comments
Post a Comment