浏览代码

Remove an incorrect distinction drawn with Objective-C (#5224)

An Objective-C method call will not be ignored when the object doesn't
define the method. It will crash with a runtime exception.

The author may have been thinking of the way an Objective-C method call
will be ignored when the object is nil. But that's not the case when the
object is there and lacks the method. In that case, the runtime will
call -doesNotRecognizeSelector:. The default behavior in the root class
NSObject is to raise an exception (not the try/catch kind; a similar
case is array bounds checks) and deliberately crash.

https://developer.apple.com/documentation/objectivec/nsobject/1418637-doesnotrecognizeselector?language=objc
Kevin Conner 3 年之前
父节点
当前提交
c6e58d8fad
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      tutorials/scripting/gdscript/gdscript_advanced.rst

+ 2 - 2
tutorials/scripting/gdscript/gdscript_advanced.rst

@@ -515,8 +515,8 @@ Yes, we should call it Hulk typing instead.
 
 It's possible that the object being hit doesn't have a smash() function.
 Some dynamically typed languages simply ignore a method call when it
-doesn't exist (like Objective C), but GDScript is stricter, so
-checking if the function exists is desirable:
+doesn't exist, but GDScript is stricter, so checking if the function
+exists is desirable:
 
 ::