问题
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?
回答1:
All that needs to be done is to declare a init withough any paramaters:
class Media: NSObject {
override init() { }
}
来源:https://stackoverflow.com/questions/53234459/how-to-have-initializers-in-a-class-but-still-be-able-to-access-the-classs-valu