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

iOS

IBOuletCollection not connecting to images. (Objecive-C)

So I have 12 Image views in my first ViewController, and I created a IBOutletCollection property to connect all the images to the same property. When I go to try and connect the IBOuletCollection to my images, it doesn't allow me. I don't know if this a xcode glitch, but its frustrating and I can't seem to find a solution. Any help would be great, thanks.

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

Try connecting the image to the IBOutletCollection instead. If that doesn't work, make sure that the image views are in the same view controller as the code for the IBOutletCollection. If that doesn't work, maybe kill and restart Xcode?

Still, no luck made sure everything was correct and good to go; maybe it could be a glitch in XCode? I'm using 8.3.3. It works when I used it for buttons, but the same doesn't apply to images.

Michael Hulet
Michael Hulet
47,913 Points

Perhaps this is a stupid question, but it's an important one: Are you sure that your IBOutletCollection is of the type NSArray <UIImageView *> *?

Wow, I actually had it the other way around; I didn't even notice because I thought it couldn't be so simple of an error, lol. Thanks so much for the help.

Actually, I had it right the first time, now I have no idea what I'm doing wrong.

Last update, I had "UIImage" as the class collection and not "UIImageView." We're good to go, thanks for the help, very much appreciated.

Michael Hulet
Michael Hulet
47,913 Points

Thant was the next question I was gonna ask. I'm glad you got it fixed!