私の問題の簡単な例:
「BlahDataController.h 内」
@interface BlahDataController : NSObject
-(NSString *)aMethod:(NSString *)theString;
@end
「BlahDataController.m 内」
#import "BlahDataController.h"
@implementation BlahDataController
-(NSString *)aMethod:(NSString *)theString
{
return @"Something";
}
@end
「BobViewController.h 内」
@interface BobViewController : NSObject
-(void)aMethodOfSomeSort;
@end
「BobViewController.m内」
#import "BobViewController.h"
#import "BlahDataController.h"
@implementation BobViewController
-(void)aMethodOfSomeSort
{
BlahDataController *blahDataController = [[BlahDataController alloc] init];
NSLog(@"%@",[blahDataController aMethod:@"Variable"]);
}
@end
行 "NSLog(@"%@",[blahDataController aMethod:@"Variable"]);" 「'BlahDataController' の目に見える @interface がセレクター 'aMethod:' を宣言していません」というエラーが表示される
このエラーが発生する理由を知っている人はいますか?
-=-=-=-=-=-=-=-=-=-=-
問題は、私の実際のプログラムでは、これと同じ実装があり、この方法で作成された何百ものメソッドに対して正常に機能することです。ただし、新しく作成されたメソッドでこのエラーが頻繁に発生します。私はそれを別の方法で作ったわけではありません。新しく作られた存在だと認識しないだけです。
-=-=-=-=-=-=-=-=-=-=-
これは私が現在行っている方法ですが、コンパイラがこの方法を受け入れる理由はわかりませんが、他の方法は受け入れません。
BobViewController.m を変更します。
#import "BobViewController.h"
#import "BlahDataController.h"
#import "AnotherDataController.h"
@implementation BobViewController
-(void)aMethodOfSomeSort
{
BlahDataController *blahDataController = [[BlahDataController alloc] init];
AnotherDataController *anotherDataController = [[AnotherDataController alloc] init];
[anotherDataController fixedMethod:blahDataController theString:@"Variable"];
}
@end
「AnotherDataController.h 内」
@interface AnotherDataController : NSObject
-(void)fixedMethod:(BlahDataController *)blahDataController theString:(NSString *)theString;
@end
「AnotherDataController.m内」
#import "AnotherDataController.h"
#import "BlahDataController.h"
@implementation AnotherDataController
-(void)fixedMethod:(BlahDataController *)blahDataController theString:(NSString *)theString
{
NSLog(@"%@",[blahDataController aMethod:theString]);
}
@end
そして....それはうまく動作します...だから、xcodeはあるクラスのメソッドを認識できず、別のクラスでは正常に動作していると思います...男、なぜこのエラーが発生しているのかわかりません.. .
-=-=-
マイナー アップデート:
「xcode ダンス」全体を実行しても問題は解決しませんでした
1) クリーン ビルド
2) 派生データを削除
3) XCode を完全に閉じて再度開く