Swift VS NSObject

Source: Internet
Author: User

Any class this does not inherit from another class is known as a base class.

Swift classes does not inherit from a universal base class. Classes you define without specifying a superclass automatically become base Classes for your to build upon.

Swift classes does not inherit from a universal base class. Classes you define without specifying a superclass automatically become base Classes for your to build upon.

According to the language reference, there are no requirement for classes to subclass any standard root class, so can I Nclude or omit a superclass as needed.

Note that omitting a superclass from the class declaration, doesn ' t assign a implicit base superclass of any kind. It defines a base class, which would effectively become the root for an independent class hierarchy.

From the Language reference:

Swift classes does not inherit from a universal base class. Classes you define without specifying a superclass automatically become base Classes for your to build upon.

Trying to reference from super a class without a super class (i.e. a base class) would result in a compile time error

‘super‘ members cannot be referenced in a root class
https://stackoverflow.com/questions/24057525/swift-native-base-class-or-nsobjecthttps://docs.swift.org/ Swift-book/languageguide/inheritance.html Swift, an object may not inherit from the NSObject
-Continue from NSObject you can use the KVC method to set the value of the property = "If it is a model object, it is best to use NSObject
-If the object has no attributes, or does not rely on KVC, you can create an object without the parent class! , the magnitude of the object is lighter, and when loaded, it is created in memory
What, 49357225 less memory consumption

Swift VS NSObject

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.