[Foundation] Fix crash when calling NSUndoManager.PrepareWithInvocationTarget