Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

samuelbird

macrumors newbie
Original poster
Hello, I am very new to objective c and have decided to learn some so I can try and make some apps and what not for fun. I am very young but I know a fair bit of Java, quite a bit of EE standard web dev, and also a little Python. Anyway, I was following a short tutorial by this guy and I have come across an issue. My ViewController.m is here:

Code:
//
//  ViewController.m
//  basicsvapp
//
//  Created by Samuel Bird on 19/04/2014.
//  Copyright (c) 2014 Samuel Bird. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    label.text = @"Hello Again";
    
    [self.view addSubView:label];

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

@end

After
Code:
[self.view addSubView:label];
, there is the error "No visible @interface for 'UIView' declares the selector 'addSubView'" which I have read about and is quite common. However, I am not sure how to fix it. I would appreciate some advice.

Sam

P.s. Just in case, my ViewController.h is here:

Code:
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end
 
It is

Code:
addSubview

Not

Code:
addSubView

(capitalization)

edit: xcode should autocomplete this as you type "[self.view addSu..."
 
Last edited:
Thanks, you are right. That was very silly.

As already said there are no silly mistakes if you learn from them but
also get use to it, you'll make 1000's of silly mistakes while learning. 🙂

Probably just as many once you've learnt.
 
It was just me getting to grips. I wanted to learn about the different UI elements. I have been using interface builder since. 🙂
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.