目标c类的默认基类 [英] Default base class for objective c classes

查看:138
本文介绍了目标c类的默认基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题的答案可能很明显,但我需要确定:



所有目标c类在基数时共享一个共同的默认基类class是不是在类定义中明确定义了?

解决方案

不,如果没有在类定义中明确定义超类你正在创建一个


  • 用于定义新根类的用例是什么?



  • The answer to this question may be obvious but I need to ask it to be certain:

    Do all objective c classes share a common default base class when a base class is not explicity defined in the class definition?

    解决方案

    No, if you do not explicitly define a super class in the class definition you are creating a root class.

    From Cocoa Core Competencies:

    A root class inherits from no other class and defines an interface and behavior common to all objects in the hierarchy below it. All objects in that hierarchy ultimately inherit from the root class. A root class is sometimes referred to as a base class.

    The root class of all Objective-C classes is NSObject, which is part of the Foundation framework. All objects in a Cocoa or Cocoa Touch application ultimately inherit from NSObject. This class is the primary access point whereby other classes interact with the Objective-C runtime. It also declares the fundamental object interface and implements basic object behavior, including introspection, memory management, and method invocation. Cocoa and Cocoa Touch objects derive the ability to behave as objects in large part from the root class.

    The Foundation framework defines another root class, NSProxy, but this class is rarely used in Cocoa applications and never in Cocoa Touch applications.

    See also:

    这篇关于目标c类的默认基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆