no visible @interface for declares the selector errors

Nihir picture Nihir · Dec 22, 2013 · Viewed 30.4k times · Source

I'm getting No visible @interface for 'NSObject' declares the selector 'viewDidLoad' on the lines:

[super viewDidLoad];

[_viewWeb loadRequest:requestObj];

[super didReceiveMemoryWarning];

UIViewControllerHUB.m

#import "UIViewControllerHUB.h"

@interface UIViewControllerHUB ()
@property (strong, nonatomic) NSMutableArray *subItems;
@end

@implementation UIViewControllerHUB

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *fullURL = @"http://conecode.com";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [_viewWeb loadRequest:requestObj];
}

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

@end

UIViewControllerHUB.h

#import <Foundation/Foundation.h>

@interface UIViewControllerHUB : NSObject
@property (strong, nonatomic) IBOutlet UIView *viewWeb;

@end

How can I fix this?


EVERYTHING ABOVE IS NOW RESOLVED.

New error below:

Now getting 'No visible @interface for 'UIView' declares the selector 'loadRequest:' on line

    [_viewWeb loadRequest:requestObj];

Answer

jszumski picture jszumski · Dec 22, 2013

viewDidLoad is a UIViewController method. To fix it, change to inherit from that:

#import <Foundation/Foundation.h>

@interface UIViewControllerHUB : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewWeb;

@end