快速的問題。我有一個沒有實現文件的類的項目。是否有編譯器標誌,以便鏈接器警告我這個? .h文件不帶.m文件
然後在AppDelegate中我有:
#import "AppDelegate.h"
#import "SomeClass.h"
@interface AppDelegate()
@property (nonatomic, strong) SomeClass *myProperty;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.myProperty hello];
// self.myProperty = [[SomeClass alloc] init]; // uncomment and fails as expected.
return YES;
}
不應該有人告訴我,有沒有實現文件?某種警告或任何事情?
如果我做了一個alloc] init],它不會按預期編譯。
該代碼實際編譯。
這是github中的項目。
https://github.com/nmiyasato/noImplementation
由於
如果某個類沒有實現,它將無法鏈接。警告通常是用於編譯和鏈接的東西,但可能是錯誤的。 – dan
應該有一個擴展名爲.a的庫文件,或者應該有一些與之相關的SDK(框架)。 – Smile
該代碼實際編譯...我已經添加了一個示例項目。 – miya