Robin
Robin

Reputation: 11

new referencing outlet, view to UIviewcontroller

So, I'm following this tutorial on youtube. I want to add a pie chart to my app. However, when I try adding a new referencing outlet from my PieChart view to my view controller(done at 5:01), Xcode doesn't let me do that. Any way to fix this?

Here's my view controller.m

//
//  checkAttendanceViewController.m
//  timetable app
//
//  Created by Robin Malhotra on 29/12/13.
//  Copyright (c) 2013 Robin's code kitchen. All rights reserved.
//

#import "checkAttendanceViewController.h"

@interface checkAttendanceViewController ()

@end

@implementation checkAttendanceViewController

@synthesize pieChartView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray *array=[[NSMutableArray alloc]init];

    for (int i=0; i<5; i++)
    {
        NSNumber *number=[NSNumber numberWithInt:rand()%60+20];
        [array addObject:number];

    }

    [self.pieChartView renderInLayer:self.pieChartView dataArray:array];

        // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

and my viewcontroller.h

//
//  checkAttendanceViewController.h
//  timetable app
//
//  Created by Robin Malhotra on 29/12/13.
//  Copyright (c) 2013 Robin's code kitchen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DLPieChart.h"


@interface checkAttendanceViewController : UIViewController
@property(nonatomic,retain) IBOutlet DLPieChart *pieChartView;
@end

Here's a dropbox link if anyone wants to try it out themselves(I know I'm not supposed to share external links, but I've pasted appropriate code and I'm not sure how you paste a storyboard in stackoverflow

Upvotes: 0

Views: 2262

Answers (3)

Robin
Robin

Reputation: 11

Okay, it suddenly started working. I quitted and restarted Xcode, cleaned the project, and voila, it works now. Should I remove this question now?.

Upvotes: 0

Abhinav
Abhinav

Reputation: 38162

Ok. I see the issue. You have wrongly set the name of the viewController class as "checkAttendanceViewContriller" instead of "checkAttendanceViewController" in your story board view controller. Change the name and you will be good to go.

Upvotes: 0

Mike Vosseller
Mike Vosseller

Reputation: 4197

When this happens to me it is usually because the view's class type in the xib does not match the outlet class type in the source file.

  • Select the view in your storyboard or xib
  • Choose View->Utilities->Show Identity Inspector (visible on the right side of Xcode)
  • Ensure the "Custom Class" textfield is set to "DLPieChart" (the type defined in your outlet)

Upvotes: 1

Related Questions