Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Garrett Cox
Garrett Cox
4,797 Points

Passing property to UIView from VC?

The image is downloaded in the VC and a UIView which is a part of that VC i want to pass the image to the UIView class.

4 Answers

Are you saying that you have a UIView subclass that's more than just a UIImageView, and you want to pass the image into that view to display it? In that case, you should make a new UIImage @property in your UIView subclass, and then (assuming you have a @property referencing it in your VC) just set that view property from your VC.

You don't need to access the UIView, you can simply do this in you VC class file :

self.yourImageViewName.Image = yourImageName ;

You can make a new class file of type UIView controller with a @property of type UIImage * and assign your UIView to it, then pass your image to that property.

if you want my opinion, you should add ImageView to your VC and pass your image to it (imageView.image).

Garrett Cox
Garrett Cox
4,797 Points

Perfect Mohammed. My VC has a property that is a UIImageView. But i need the UIView to access that. How do i pass a property from my VC to a UIView?