Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no visible @interface for declares the selector errors

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];
like image 752
Nihir Avatar asked Nov 02 '22 08:11

Nihir


2 Answers

In your code 'No visible @interface for UIView declares the selector 'loadRequest:' on line why you are getting this error is becuase loadRequest is not the method of UIView. But in-spite of that it is the method of UIWebView. For more refer this UIWebView documentation . So just replace UIView to UIWebView and check

//Comment this

//@property (strong, nonatomic) IBOutlet UIView *viewWeb;

//Modify this

@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;

Note:- As you have created outlet of UIView. So delete the same and drag-drop UIWebView and then reconnect the outlet to UIWebView

like image 99
Hussain Shabbir Avatar answered Nov 15 '22 06:11

Hussain Shabbir


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
like image 44
jszumski Avatar answered Nov 15 '22 07:11

jszumski