美文网首页
isKindOfClass: & isMemberOfClas

isKindOfClass: & isMemberOfClas

作者: 自律_自强_通达 | 来源:发表于2020-11-06 08:57 被阅读0次

    import "ViewController.h"

    import "Person.h"

    @implementation ViewController

    • (void)viewDidLoad {
      [super viewDidLoad];
      NSLog(@"%@", [NSObject class]);

      NSLog(@"%d", [[NSObject class] isKindOfClass:[NSObject class]]);
      // YES

      NSLog(@"%d", [[Person class] isKindOfClass:[NSObject class]]);
      // YES

      NSLog(@"%d", [[Person class] isMemberOfClass:[NSObject class]]);
      // NO

      NSLog(@"%d", [[Person new] isMemberOfClass:[NSObject class]]);
      // NO

      Person *p = [Person new];
      NSLog(@"%d", [[p class] isMemberOfClass:[Person class]]);
      // NO

      NSLog(@"%d", [p isMemberOfClass:[Person class]]);
      // YES
      }

    @end

    相关文章

      网友评论

          本文标题:isKindOfClass: & isMemberOfClas

          本文链接:https://www.haomeiwen.com/subject/qgwzvktx.html