How to have initializers in a class but still be a

2019-06-13 04:21发布

I have a function that only needs to access one value inside an object with has initializers.

ImageUploadManager().sendImages(self.images, postID: postID, image: Media().postImage)

However doing so yields the following error:

Cannot invoke initializer for type 'Media' with no arguments

So my question is: is it possible to access a value as I do here withought having to initialize?

标签: swift class
1条回答
劳资没心,怎么记你
2楼-- · 2019-06-13 04:30

All that needs to be done is to declare a init withough any paramaters:

    class Media: NSObject {

    override init() { }
}
查看更多
登录 后发表回答