Skip to content

Commit

Permalink
Fixed mix-up between 09_Undo/RaiseMan_A and 09_Undo/RaiseMan_B.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Yedidia committed Jun 2, 2008
1 parent 6c225a8 commit bdbfd5b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions 09_Undo/RaiseMan_A/RaiseMan.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; };
AB0670A50DED05BE00E0ABDA /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB0670A40DED05BE00E0ABDA /* Nu.framework */; }; AB0670A50DED05BE00E0ABDA /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB0670A40DED05BE00E0ABDA /* Nu.framework */; };
AB0670A70DED05E400E0ABDA /* main.nu in Resources */ = {isa = PBXBuildFile; fileRef = AB0670A60DED05E400E0ABDA /* main.nu */; }; AB9402F70DF385F400D31812 /* main.nu in Resources */ = {isa = PBXBuildFile; fileRef = AB9402F60DF385F400D31812 /* main.nu */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */


/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
Expand All @@ -31,7 +31,7 @@
8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D15AC370486D014006FF6A4 /* RaiseMan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RaiseMan.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D15AC370486D014006FF6A4 /* RaiseMan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RaiseMan.app; sourceTree = BUILT_PRODUCTS_DIR; };
AB0670A40DED05BE00E0ABDA /* Nu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nu.framework; path = /Library/Frameworks/Nu.framework; sourceTree = "<absolute>"; }; AB0670A40DED05BE00E0ABDA /* Nu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nu.framework; path = /Library/Frameworks/Nu.framework; sourceTree = "<absolute>"; };
AB0670A60DED05E400E0ABDA /* main.nu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.nu; path = nu/main.nu; sourceTree = "<group>"; }; AB9402F60DF385F400D31812 /* main.nu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.nu; path = nu/main.nu; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */


/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -119,7 +119,7 @@
AB0670A30DED05A900E0ABDA /* Nu */ = { AB0670A30DED05A900E0ABDA /* Nu */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
AB0670A60DED05E400E0ABDA /* main.nu */, AB9402F60DF385F400D31812 /* main.nu */,
); );
name = Nu; name = Nu;
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -171,7 +171,7 @@
8D15AC2D0486D014006FF6A4 /* MainMenu.nib in Resources */, 8D15AC2D0486D014006FF6A4 /* MainMenu.nib in Resources */,
8D15AC2E0486D014006FF6A4 /* MyDocument.nib in Resources */, 8D15AC2E0486D014006FF6A4 /* MyDocument.nib in Resources */,
8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */, 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */,
AB0670A70DED05E400E0ABDA /* main.nu in Resources */, AB9402F70DF385F400D31812 /* main.nu in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
29 changes: 1 addition & 28 deletions 09_Undo/RaiseMan_A/nu/main.nu
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,39 +17,12 @@
(else (super setNilValueForKey:key))))) (else (super setNilValueForKey:key)))))


(class MyDocument is NSDocument (class MyDocument is NSDocument
(ivar (id) employees (id) employeeController (id) tableView) (ivar (id) employees)


(- (id) init is (- (id) init is
(super init) (super init)
(self setEmployees:(array)) (self setEmployees:(array))
self) self)

(- (BOOL) endEditing is
(set w (@tableView window))
(set editingEnded (w makeFirstResponder:w))
(unless (editingEnded) NO)
(set undo (self undoManager))
(if (undo groupingLevel)
(undo endUndoGrouping)
(undo beginUndoGrouping))
YES)

(- (void) createEmployee: (id) sender is
; If a field is being edited, end editing
(unless (eq NO (self endEditing))

(set p (@employeeController newObject))
(@employeeController addObject:p)

; In case the user has sorted the content array
(@employeeController rearrangeObjects)

; Find the row of the new object
(set a (@employeeController arrangedObjects))
(set row (a indexOfObjectIdenticalTo:p))

; Start editing in the first column
(@tableView editColumn:0 row:row withEvent:nil select:YES)))


(- (void) startObservingPerson: (id) person is (- (void) startObservingPerson: (id) person is
(person addObserver:self (person addObserver:self
Expand Down
8 changes: 4 additions & 4 deletions 09_Undo/RaiseMan_B/RaiseMan.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; };
AB1DE74D0DF37472008275EC /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB1DE74C0DF37472008275EC /* Nu.framework */; }; AB1DE74D0DF37472008275EC /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB1DE74C0DF37472008275EC /* Nu.framework */; };
AB1DE7510DF37490008275EC /* main.nu in Resources */ = {isa = PBXBuildFile; fileRef = AB1DE7500DF37490008275EC /* main.nu */; }; AB9403130DF3861600D31812 /* main.nu in Resources */ = {isa = PBXBuildFile; fileRef = AB9403120DF3861600D31812 /* main.nu */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */


/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
Expand All @@ -31,7 +31,7 @@
8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D15AC370486D014006FF6A4 /* RaiseMan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RaiseMan.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D15AC370486D014006FF6A4 /* RaiseMan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RaiseMan.app; sourceTree = BUILT_PRODUCTS_DIR; };
AB1DE74C0DF37472008275EC /* Nu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nu.framework; path = /Library/Frameworks/Nu.framework; sourceTree = "<absolute>"; }; AB1DE74C0DF37472008275EC /* Nu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nu.framework; path = /Library/Frameworks/Nu.framework; sourceTree = "<absolute>"; };
AB1DE7500DF37490008275EC /* main.nu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.nu; path = ../RaiseMan_A/nu/main.nu; sourceTree = SOURCE_ROOT; }; AB9403120DF3861600D31812 /* main.nu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.nu; path = nu/main.nu; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */


/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -119,7 +119,7 @@
AB1DE7480DF37461008275EC /* Nu */ = { AB1DE7480DF37461008275EC /* Nu */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
AB1DE7500DF37490008275EC /* main.nu */, AB9403120DF3861600D31812 /* main.nu */,
); );
name = Nu; name = Nu;
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -171,7 +171,7 @@
8D15AC2D0486D014006FF6A4 /* MainMenu.nib in Resources */, 8D15AC2D0486D014006FF6A4 /* MainMenu.nib in Resources */,
8D15AC2E0486D014006FF6A4 /* MyDocument.nib in Resources */, 8D15AC2E0486D014006FF6A4 /* MyDocument.nib in Resources */,
8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */, 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */,
AB1DE7510DF37490008275EC /* main.nu in Resources */, AB9403130DF3861600D31812 /* main.nu in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
29 changes: 28 additions & 1 deletion 09_Undo/RaiseMan_B/nu/main.nu
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,12 +17,39 @@
(else (super setNilValueForKey:key))))) (else (super setNilValueForKey:key)))))


(class MyDocument is NSDocument (class MyDocument is NSDocument
(ivar (id) employees) (ivar (id) employees (id) employeeController (id) tableView)


(- (id) init is (- (id) init is
(super init) (super init)
(self setEmployees:(array)) (self setEmployees:(array))
self) self)

(- (BOOL) endEditing is
(set w (@tableView window))
(set editingEnded (w makeFirstResponder:w))
(unless (editingEnded) NO)
(set undo (self undoManager))
(if (undo groupingLevel)
(undo endUndoGrouping)
(undo beginUndoGrouping))
YES)

(- (void) createEmployee: (id) sender is
; If a field is being edited, end editing
(unless (eq NO (self endEditing))

(set p (@employeeController newObject))
(@employeeController addObject:p)

; In case the user has sorted the content array
(@employeeController rearrangeObjects)

; Find the row of the new object
(set a (@employeeController arrangedObjects))
(set row (a indexOfObjectIdenticalTo:p))

; Start editing in the first column
(@tableView editColumn:0 row:row withEvent:nil select:YES)))


(- (void) startObservingPerson: (id) person is (- (void) startObservingPerson: (id) person is
(person addObserver:self (person addObserver:self
Expand Down

0 comments on commit bdbfd5b

Please sign in to comment.