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

init methods, what causes them not to properly execute?

Im creating a UICollectionViewFlowLayout inside the init method of my UICollectionView.

-(instancetype)init
{
    self = [super init];


    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake(106, 106);
    layout.minimumInteritemSpacing = 1.0;
    layout.minimumLineSpacing = 1.0;


    return (self = [super initWithCollectionViewLayout:layout]);
}

My delegate/datasource methods and viewDidLoad seems to execute, but for some reason if I add a breakpoint on the init method, it just silently fails.

Is it because the breakpoint causes everything conected to init method to quit along with the method?

No that's not the reason. Without the breakpoint the init method still wouldn't execute. The break point was added to see if it that block of code was being executed.

A breakpoint added at the ViewDidLoad halts execution.

Sorry it took so long to get back. If you haven't got it yet I think you mist a space, you wrote:

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];

instead write this:

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];