zoukankan      html  css  js  c++  java
  • + (void)initialize vs 静态构造方法

    在继承体系中,多个子类的引用,父类缺省执行一次;

    特殊情况:

    1)子类没有实现、调用父类方法;

    2)子类显示调用父类;

    3)存在分类实现,分类实现覆盖本体。

    Initializes the class before it receives its first message.

    The runtime sends initialize to each class in a program just before the class, or any class that inherits from it, is sent its first message from within the program. Superclasses receive this message before their subclasses.

    The runtime sends the initialize message to classes in a thread-safe manner. That is, initialize is run by the first thread to send a message to a class, and any other thread that tries to send a message to that class will block until initialize completes.

    The superclass implementation may be called multiple times if subclasses do not implement initialize—the runtime will call the inherited implementation—or if subclasses explicitly call [super initialize]. If you want to protect yourself from being run multiple times, you can structure your implementation along these lines:

  • 相关阅读:
    layoutSubviews, setNeedsLayout, layoutIfNeeded
    UIViewController 专题
    UIBarButtonItem
    ios method swizzling
    Method Swizzling
    ios逆向工程
    IOS中通知中心NSNotificationCenter应用总结
    Swift 进阶
    swift 2.0 语法 字符串
    C++Builder中MessageBox的基本用法
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8399308.html
Copyright © 2011-2022 走看看