`NSUndoManager` is a general-purpose recorder of operations for undo and redo.
Questions tagged [nsundomanager]
222 questions
29
votes
5 answers
Xcode LLDB Print Statements Fail - NSUndoManager
I have a breakpoint set and want to print my UITextField's superview. I type po myTextField.superview but I receive the following error:
error: instance method 'undoManager' has incompatible result types in different translation units ('id' vs.…

rizzes
- 1,532
- 20
- 33
17
votes
2 answers
Cocoa: looking for a general strategy for programmatic manipulation of NSTextView storage without messing up undo
I am writing a special-purpose text editor in cocoa that does things like automatic text substitution, inline text completions (ala Xcode), etc.
I need to be able to programmatically manipulate the NSTextView’s NSTextStorage in response to 1) user…

pjv
- 566
- 3
- 16
12
votes
1 answer
How to implement undo/redo in UIWebView
I am developing an app which has rich text editor feature. On top of ZSSRichTextEditor I have written my editor code. Here my editor is UIWebView which will be injected by javascript code to support/edit the rich text content.
ZSSRichTextEditor has…

thavasidurai
- 1,972
- 1
- 26
- 51
11
votes
3 answers
Is it OK to use multiple NSUndoManagers with one Core-Data managedObjectContext?
//Edit: Really, nobody has any suggestions or thoughts on this? Have I asked the question wrongly somehow?//
My iPhone app has a single managedObjectContext with a moderately complicated data model. I'm now adding undo functionality, and am not…

mackworth
- 5,873
- 2
- 29
- 49
11
votes
8 answers
How do I register UndoManager in Swift?
How do I use UndoManager (previously NSUndoManager) in Swift?
Here's an Objective-C example I've tried to replicate:
[[undoManager prepareWithInvocationTarget:self] myArgumentlessMethod];
Swift, however, seems to not have NSInvocation, which…

Kevin Griffin
- 14,084
- 7
- 28
- 23
10
votes
4 answers
How can I replace text in UITextView with NSUndoManager support?
I want to be able to replace some text in an UITextView programatically, so I wrote this method as an UITextView category:
- (void) replaceCharactersInRange:(NSRange)range withString:(NSString *)newText{
self.scrollEnabled = NO;
…

nacho4d
- 43,720
- 45
- 157
- 240
10
votes
3 answers
Something very strange UITextView in iOS 7 ... not in iOS 6?
I'm creating a UITextView:
greetingTextView = [[UITextView alloc] initWithFrame:greetingRect];
Using it fine, but when the ViewController it is attached to deallocs I'm getting memory leaks ONLY in iOS 7 ? I'm even Nulling the greetingTextView out…

Aardvark
- 608
- 5
- 15
9
votes
1 answer
iOS - UITextView + NSUndoManager
I'm trying to integrate the undo/redo features in a UITextView (I'm building a LateX editor) with no luck and to be honest I'm really confused about this argument. I don't understand the steps involved in those two operations, I mean I need two…

oiledCode
- 8,589
- 6
- 43
- 59
9
votes
1 answer
undo all changes made in the child view controller
There are two entities: Author and Book. Author has an attribute authorName and a to-many relationships books. Book has several attributes and a relationship author. There is a view controller (VCAuthor) to edit an Author object. The child view…

lu yuan
- 7,207
- 9
- 44
- 78
8
votes
3 answers
NSUndoManager, Core Data and selective undo/redo
I'm working on a core data application that has a rather large hierarchy of managed objects similar to a tree.
When a base object is created, it creates a few child objects which in turn create their own child objects and so on. Each of these child…

Arlen Anderson
- 2,486
- 2
- 25
- 36
8
votes
3 answers
Using NSUndoManager and .prepare(withInvocationTarget:) in Swift 3
I am migrating an Xcode 7 / Swift 2.2 mac OS X project to Xcode 8 / Swift 3, and I have run into a problem using undoManager in my view controller class, MyViewController, which has a function undo.
In Xcode 7 / Swift 2.2, this worked…

jbaraga
- 656
- 5
- 16
7
votes
3 answers
How can I make NSUndoManager's undo/redo action names work properly?
I'm learning Cocoa, and I've gotten undo to work without much trouble. But the setActionName: method is puzzling me. Here's a simple example: a toy app whose windows contain a single text label and two buttons. Press the On button and the label…

Gabriel Roth
- 1,030
- 1
- 12
- 31
7
votes
1 answer
Using NSUndoManager, how to register undos using Swift closures
I am trying to grok how to use NSLayoutManager using Swift closures. I can successfully register an undo as follows:
doThing();
undoManager?.registerUndoWithTarget(self, handler: { _ in
undoThing();
}
undoManager?.setActionName("do thing")
Of…

wcochran
- 10,089
- 6
- 61
- 69
7
votes
1 answer
NSUndoManager and enabling/disabling an undo button
In my iOS application's interface I have explicit undo & redo button (shake-to-undo is a pretty heavyweight action and in this context, undos are performed pretty frequently). Normally, I would use KVO to observe NSUndoManager's canUndo and canRedo…

Colin Barrett
- 4,451
- 1
- 26
- 33
7
votes
3 answers
NSUndoManager undo Not Working With Core Data
I am trying to create an iPhone application where the user can add entries. When he presses a new entry, a box will popup asking him for some information. Then he can either press "Cancel" or "Save" to discard the data or save it to disk.
For…

kkrizka
- 893
- 1
- 11
- 16