Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mdeh

macrumors 6502
Original poster
Jan 3, 2009
345
2
I am sure there is a simple answer, but I have not seen it anywhere.


In Hillegass, the method
- (NSData *)dataOfType: (NSString *)typeName error: (NSError **)outError

is edited to archive the document.

One of the calls to stop all editing is:
[[ tableView window] endEditingFor: nil];

The documentation says of the argument for "endEditingFor"
The object that is using the window’s field editor

Could anyone help me understand then why "nil" is provided as an argument, when it is supposed to be directed at an object using the field editor...in other words...what objects are supposed to be receiving this message. It obviously works, but I am just trying to figure out why.

Thanks as always.
 
Taken from: http://discussions.apple.com/thread.jspa?messageID=9825472

When thisObject is valid and using the field editor, the field editor is forced to resign first responder status, send textDidEndEditing: to its delegate and disassociate from thisObject. When thisObject is nil, if the field editor is first responder, it must similarly resign and end editing regardless of which object it's associated with.

An object might send endEditingFor:self when finished editing in a case where no other object has asked to become first responder. The window controller might send endEditingFor:nil if the first responder needs to change but the field editor refuses to give up first responder (for example because the current text is invalid). AFAIK, if myObject is the object with the field editor, endEditingFor:myObject does the same thing as endEditingFor:nil. Passing nil just saves the caller from trying to find out which object, if any, has the field editor.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.