0

What I want to do is pretty simple but I don't understand what I am doing wrong. I have button that upon clicked, will go to another page. The method that loads a different page is in different class and upon initializing it where I want to use it, I can't see none of the methods belonging to the class.

Here is what I have

//HomeViewController.h

#import <UIKit/UIKit.h>
#import "PhotoView.h"
#import <CoreLocation/CoreLocation.h>
#import "Reachability.h"
#import "BottomTableViewController.h"

@protocol HomeViewControllerDelegate <NSObject>

    @optional
    - (void)moveToShowBottomTableView;
    - (void)moveToHideBottomTableView;
    - (void)sendDescriptionToBottomTableView;

@end

@interface HomeViewController : UIViewController<UIScrollViewDelegate, BottomTableViewControllerDelegate>{
    IBOutlet UIScrollView *gridView;

    CLLocationManager *locationManager;
    CLLocationCoordinate2D userCoordinate;
    CLLocation *initialCoordinate;

    Reachability *internetReachable;
    Reachability *hostReachable;

}

@property (assign, nonatomic) int fromMapView;
@property (retain, nonatomic) NSArray *clusteredPhotoIDs;
@property (strong, nonatomic) IBOutlet UILabel *schoolTitle;

@property (strong, nonatomic) IBOutlet UIButton *showDetailsButton;
@property (assign, nonatomic) id<HomeViewControllerDelegate> delegate;
@property (strong, nonatomic) IBOutlet UILabel *bottomTableViewTitle;
- (IBAction)refreshButton:(id)sender;
- (IBAction)next:(id)sender;
- (IBAction)prev:(id)sender;

@property (retain, nonatomic) NSString *subviewDescription;
@property (retain, nonatomic) NSString *subviewCopyright;
@property (retain, nonatomic) NSString *subviewAddress;
@property (retain, nonatomic) NSString *photoIDNumber;

@end

BottomPanelViewController.m

 #import "HomeViewController.h"
-(IBAction)nextPage:(id)sender{
    HomeViewController *homeScreen = [[HomeViewController alloc] init];
   // [homeScreen loadPage];//THIS DOESN'T WORK
}

HomeViewController.m

- (void)loadPage:(NSInteger)page {
    // Do stuff
}

I get this error in the part marked as "Doesn't work": no visible @interface for HomeViewController declares the selector loadPage

Thanks for any help you can offer.

4
  • Define "doesn't work". Compiler error? Run time error? Is loadPage actually called but doesn't do what you want? Please update your question with relevant details. Commented Aug 11, 2015 at 16:48
  • no visible @interface for HomeViewController declares the selector loadPage Commented Aug 11, 2015 at 16:52
  • 1
    are you actually presenting/pushing the new view controller (homeScreen)? If not, that is most likely your problem. Commented Aug 11, 2015 at 16:54
  • What does HomeViewController.h look like? Commented Aug 11, 2015 at 17:11

2 Answers 2

2

It seams that your method receive an integer and you are not sending anything [homeScreen loadPage: (NSInteger) ];

- (void)loadPage:(NSInteger)page {
    // Do stuff
}
Sign up to request clarification or add additional context in comments.

Comments

0

Ah. You need to add the method declaration to the .h file. add the line - (void)loadPage:(NSInteger)page; in your @interface section of the HomeViewController.h file. That will make the method available for use outside its class.

Edit: Also, I stand by what I said before, you also need to present the new view controller somehow...

Another Edit: You also need to make sure that the method names and parameter lists are equivalent.

3 Comments

But the OP isn't trying to call loadPage:. They are trying to call a method named loadPage (note the lack of a parameter).
Sorry for the confusion guys, What I meant to say was that I can't see any of the methods from HomeViewController. So the part that is commented out, // [homeScreen loadPage];//THIS DOESN'T WORK wouldn't work as it is yes, but my point was that I can't see the loadPage method at all.
If you cant see the methods that are inside the class from outside the class, just add the method definition to the .h file as I had suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.