oc weak syntax
The method call of oc is to detect whether the object has implemented the corresponding method at runtime
#import <Foundation/Foundation.h> //@interface Person:NSObject //@end //Added here: NSObject @implementation Person:NSObject - (void)test { NSLog(@"test"); } @end intmain() { Person *p=[Person new]; [p test]; return 0; }
If the test method implementation is commented out, compiling and linking will not report an error; if the test method is only declared and not defined, compiling and linking will not report an error; only an error will be reported at runtime; if test is defined but not declared, compile and link and run No error will be reported, but this is not recommended; if Person does not declare it, no error will be reported as above, but this is not recommended.