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:

  • 相关阅读:
    8.指针小结
    8.指针
    7.数组
    6.结构化程序设计
    python之迭代器
    1.python基础—有这篇文章足够
    python装饰器,细致讲解
    django客户管理系统-使用modelform对HTML标签统一添加样式
    python之md5使用方法
    git干货教程
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8399308.html
Copyright © 2011-2022 走看看