2 つのメソッドを持つ Datahandler というクラスを作成しました。私の LoginViewController では使用できますが、別の ViewController では見つかりません。
これは私の DataHandler.h ファイルです:
#import <Foundation/Foundation.h>
@interface DataHandler : NSObject
- (int) loginOnServer:(NSString *)username password:(NSString *)password;
- (NSString *) getJsonFromServer;
@end
私の LoginViewController では、両方のメソッドが見つかりました。
LoginViewController.m:
#import "DataHandler.h"
...
@interface LoginViewController ()
...
@end
@implementation LoginViewController
- (void) checkLogin:(NSString *)email password:(NSString *) password
{
DataHandler *dataHandler = [[DataHandler alloc] init];
int result = [dataHandler loginOnServer:email password:password];
...
}
...
@end
FirstViewController.m:
#import "DataHandler.h"
...
@interface FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad
{
...
DataHandler *dh = [[DataHandler alloc] init];
NSString *json = [dh getJsonFromServer];
...
}
私がそこに得るものは次のとおりです。
FirstViewController.m:32:23: No visible @interface for 'DataHandler' declares the selector 'getJsonFromServer'
私は何を間違っていますか?
ありがとうございました。
編集1:
私のプロジェクト フォルダーには DataHandler という別の古いクラスがあり、このクラスの代わりに使用されました。