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:

  • 相关阅读:
    bootstrap 导航学习
    算法学习1-插入排序
    管道输入输出流
    1+2*2+3*3+4*4+...+n*n计算
    maven安装for eclipse kepler
    javascript学习7-细节总结
    Git Fetch failed解决办法
    前端学习笔记
    TIOBE 编程语言排行榜
    用VS2012创建和使用WebService
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8399308.html
Copyright © 2011-2022 走看看