How to subclass an array class in Swift?

前端 未结 4 1797
予麋鹿
予麋鹿 2021-02-20 00:05

I am new in Swift. I have a base class:

class foo{}

I want to implement a foo collection class:

class foos: Array{}
         


        
4条回答
  •  耶瑟儿~
    2021-02-20 00:18

    In Swift, Array is a struct, not a class. To have a class that is an array subclass, you will need to use NSArray, its Objective-C counterpart.

    For example,

    class Foo: NSArray{}
    

提交回复
热议问题