Reputation: 4962
I am trying to access an outlet, an imageView, which is in another class. When I type the outlet name, it generates an error, for the outlet is in another class. How do I access an imageView outlet in another class?
Code:
//Class I am trying to call the outlet in
override func viewDidLoad() {
super.viewDidLoad()
if photosAsset == nil {
//ERROR: Use of unresolved identifier: myImageView, since myImageView is in the class PhotoThumbnail
myImageView.image = ""
}
//Class with the oulet
class PhotoThumbnail: UICollectionViewCell {
@IBOutlet var myImageView : UIImageView!
}
Upvotes: 1
Views: 2012
Reputation: 3475
create a PhotoThumbnail object
var photoThumbnail = PhotoThumbnail() // Without any initializers
then
photoThumbnail.image
Since it is collectionViewCell, do it in cellforItemAtIndexPath Method
Upvotes: 2