Stuck on Silver Challenge



I’m stuck on the Silver Challenge in Chapter 7 and need some help. I’ve pasted the code that I have in the BNRHypnosisViewController.m file below. What I’m trying to do is to have the clickSelector method in BNRHypnosisViewController.m call the touchesBegan method in BNRHypnosisView.m. That’s the only way I can think of to get the colors to change (since touchesBegan already does that in BNRHypnosisView.m).

Can someone advise me? :blush:


    //Create a view
    CGRect frame = [UIScreen mainScreen].bounds;
    BNRHypnosisView * backgroundView = [[BNRHypnosisView alloc]initWithFrame:frame];
    // Create an array of segmented controls
    NSArray * colorArray = [NSArray arrayWithObjects:@"Red", @"Blue", @"Green", nil];
    // Add the array to the UISegmented control object
    UISegmentedControl *colorSegments = [[UISegmentedControl alloc]initWithItems:colorArray];
    // Configure the way the UISegmentedControl will look
    colorSegments.frame = CGRectMake(35, 450, 250, 50);
    colorSegments.selectedSegmentIndex = 1;
    [colorSegments addTarget:self action:@selector(clickSelector:) forControlEvents:UIControlEventValueChanged];
    // Set backgroundView as "the" view of this view controller
    self.view = backgroundView;
    // Add a subview which is the UISegmentedControl
    [backgroundView addSubview:colorSegments];
-(void)clickSelector:(UISegmentedControl *) control{
    NSLog(@"You've clicked a segment control %ld", (long)control.selectedSegmentIndex);
    [b][i]// ***** Need to find a way to call the touchesBegan method in BNRHypnosisView.m ********[/i][/b]