Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,842 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,842 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,842 Points

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