nsundomanager

make NSUndoManager ignore a property of an NSManagedObject

廉价感情. 提交于 2019-12-13 17:07:44
问题 My app's main function is to arrange objects on a plot. The whole thing is based on Core Data, and each object on the plot is represented by an entity. For this example, that entity will be "Unit," a custom subclass of NSManagedObject. When the plot is opened, each Unit gets a UnitViewController created, which KVO-observes changes to the Unit's properties, such as .positionX, .positionY, and .angle. Touch gestures that the UnitViewController detect modify the Unit object, and the view

Does NSUndoManager retain objects?

廉价感情. 提交于 2019-12-12 05:33:38
问题 I do the following: Path2D *pathToRemove = [path copy]; [[[self undoManager] prepareWithInvocationTarget:self] removePath:pathToRemove atIndex:index]; [pathToRemove autorelease]; I also have a clear button that does: [undoManager removeAllActions]; Problem is that the removeAllActions crashes the app. When I removed the [pathToRemove autorelease], it worked (or at least didn't crash. It could still be a memory leak). I guess I was assuming that the undoManager retained 'pathToRemove' when

Undo manager for tableView row delete

江枫思渺然 提交于 2019-12-12 03:43:25
问题 Is it possible to implement an undo manager when you delete a row in a tableView ? I have read about undo manager and you have to set the viewController as becomeFirstResponder() . The problem is that I am using a tableView inside a collectionViewCell How shall I proceed with registering an undo? I tried the following and it doesn't seem to work @IBAction func tableButtonUndo(_ sender: Any) { print("undo working") undoItem() } func tableView(_ tableView: UITableView, didSelectRowAt indexPath:

Save managedObjectContext partly

♀尐吖头ヾ 提交于 2019-12-12 01:22:57
问题 I have 3 transaction already in NSManagedObjectContext : A , B , C . They were performed / added to context in the same order. How can I save only the first A transaction, but keep unsaved B , C on context. insert A , insert B , insert C , commit A , .. Unfortunately NSManagedObjectContext can not do commit A , but save all the transactions. 回答1: Maybe I missing something. Your goal is to save a specific object, say A , only and only if A 's data has been committed to the server. Am I wrong?

How to implement undo using NSUndoManager?

只愿长相守 提交于 2019-12-11 09:13:44
问题 I am trying to add an NSUndoManager to my program but I am not sure how to register the methods with the manager? using : [myUndoManager registerUndoWithTarget:selector:object:]; what if I have the following method: -(IBAction)tapButton:(id)sender { myFoo++; yourFoo++; //incrementing integers fooFoo++; } How can I register this method with the undo manager? The object of the selector (sender) is not what I want to register. I need to decrement myFoo, yourFoo, and fooFoo with a single undo

NSUndoManager custom coalescing changes to NSTextField results in crash

匆匆过客 提交于 2019-12-11 04:17:00
问题 I have a basic Cocoa app using NSUndoManager to support undo/redo. My data model's title can be updated by editing an NSTextField . Out of the box NSTextField supports coalescing changes into a single "Undo Typing" undo action so that when the user presses Cmd-Z, the text is reverted in full instead of only the last letter. I'd like to have a single "Undo Changing Model Title" undo action that undoes multiple changes to my model's title (made in a NSTextField). I tried grouping changes myself

UITextView undo manager do not work with replacement attributed string (iOS 6)

浪子不回头ぞ 提交于 2019-12-10 15:49:14
问题 iOS 6 has been updated to use UITextView for rich text editing (a UITextView now earns an attributedText property —which is stupidly non mutable—). Here is a question asked on iOS 6 Apple forum under NDA, that can be made public since iOS 6 is now public... In a UITextView, I can undo any font change but cannot undo a replacement in a copy of the view's attributed string. When using this code... - (void) replace: (NSAttributedString*) old with: (NSAttributedString*) new { 1. [[myView

Will NSUndoManager undo changes happening in the background?

感情迁移 提交于 2019-12-10 10:16:32
问题 I've got an edit view controller which I'm using an NSUndoManager for which is the one set for my persistence store (core data project). One of the features of my app is synchronisation with an external server. What I want to know is, if I am editing something in my view, and at the same time the app is syncing itself with the server, if I change my mind and decide to undo any changes in my current edit, would it also undo all of the changes made during the sync if they were made whilst the

Three-finger undo gesture with custom undo manger

…衆ロ難τιáo~ 提交于 2019-12-08 08:02:30
I'm trying to handle the three-finger gesture with a custom undo manager. Using the default undo manager provided by the window, resolved via the UIResponder chain works flawlessly. As soon as I try to use an own undo manager in a view controller I run into issues. (Background: I want to switch between different managers depending on the state of the view, so I can't use the single undo manager provided by the window.) What I did: override undoManager in my view controller and return an own instance override canBecomeFirstResponder and return true set the VC to be the first responder on

Three-finger undo gesture with custom undo manger

霸气de小男生 提交于 2019-12-08 05:34:19
问题 I'm trying to handle the three-finger gesture with a custom undo manager. Using the default undo manager provided by the window, resolved via the UIResponder chain works flawlessly. As soon as I try to use an own undo manager in a view controller I run into issues. (Background: I want to switch between different managers depending on the state of the view, so I can't use the single undo manager provided by the window.) What I did: override undoManager in my view controller and return an own