I was trying to use PhotosPicker() in my practice project, and use #available/@availabvle to check the IOS version. I did some research, but haven't found a way to solve this issue.
class PostAndCollectionVM: ObservableObject {
@Published var houseCollection = [RoomPostDM]()
@Published var providerCollection = [RoomPostDM]()
@Published var roomData: RoomPostDM = .empty
if #available(iOS 16, *) {
@Published var selectedImage: PhotosPickerItem? = nil
} else {
@Published var selectedImage = UIImage()
}
}
Could I use #available directly in class without func or Compute property to wrap it, or could I need to use @available for the different classes like so?
@available(ios 16, *) class collectionVM {}
@available(ios, obsoleted: 15, *) clas class collectionVM2 {}