Question

First, here's the basic setup of the Storyboard

UIViewController > View > Container View -> UICollectionViewController

The embed segue between the container and the UICollectionViewController is "SegueA".

Now the target UICollectionViewController is subclassed with CustomCollectionVC.h.

And CustomCollectionVC has a public method:

- (void)updateCollection:(NSArray *)data;

The encompassing UIViewController needs a reference to CustomCollectionVC so:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"SegueA"])
    {
        customCollection = (CustomCollectionVC *)segue.destinationViewController;
    }
}

And then, at a later point (after some data has been loaded), we call:

[customCollection updateCollection:data];

However, at this point, I get the unhelpful error of:

-[UICollectionViewController updateCollection:]: unrecognized selector sent to instance 0x10bc73ef0

If this means that customCollection is not being cast properly then what am I doing wrong inside prepareForSegue?

I've seen numerous folks ask about how to reference views inside containers and they all use this method.

Any help would be greatly appreciated! Thanks!

Pas de solution correcte

Autres conseils

ok, turned out to be a very simple problem. As Philip Mills, rdelmar, and Ivan Lesko point out above, I had forgotten to set the CustomCollectionVC in the Storyboard. Damn.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top