Alexandre Cassagne
Alexandre Cassagne

Reputation: 2463

Immutable Properties That Shouldn't Be

I've come across a very strange problem, which I am trying to understand. It appears that instance variables are not working like they should...

                self.imageView.setImage(image) // This works.
                self.imageView.image = image // This does not.

With the second method, I get the following error. Cannot assign to property: self is immutable.

This is the first time it happens to me: I am not doing anything special. My image view is declared like follows, @IBOutlet var imageView: UIImageView!, and is connected in the storyboard.

The only think I can think of is that I've recently included an Objective-C bridging header; it was working fine yesterday, although I can't seem to make it work normally by removing the bridging header from the build settings.

All this is happening from a UIViewController subclass, and I mean class, not struct...

Thank you for your help.

Upvotes: 0

Views: 59

Answers (1)

Alexandre Cassagne
Alexandre Cassagne

Reputation: 2463

I found the reason behind all this. It's stupid, and I thank Nicklas Ridewing for pointing me in the right direction.

I've included https://github.com/mindbrix/UIImage-PDF (UIImage+PDF).

This code extends UIView with a method defined as

- (NSImage *) image.

I renamed it, pdf_image and all was fixed, after changing all calls to it in the library. Maybe I'll do a pull request...

Upvotes: 1

Related Questions