-
字面翻译:缺少方法声明的上下文
-
解决:Objective-C的实例方法/类方法的实现代码,需要放在@implementation 和 @end之间,才能编译通过
-
选读:我是在main.m文件写一些测试代码遇到的报错,可以直接在main.m文件写一个测试类,如下
#import <Foundation/Foundation.h>
@interface TestClass : NSObject
+ (void)test:(NSString * const)string;
@end
@implementation TestClass
+ (void)test:(NSString * const)string{
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
[TestClass test:@"998"];
}
return 0;
}
网友评论