0

I'm trying to use "CodeRunner" as Objective-C playground but I'm trying to add a new method to the class:

#import <Foundation/Foundation.h>

int main(int argc, char *argv[]) {


    @autoreleasepool {
    }
}

-(void)printSomeThing {
        NSLog("printing someThing")
}

I'm getting this error:

Untitled.m:10:1: error: missing context for method declaration
-(void)printSomeThing {
^
1 error generated.

Any of you knows how fix this error?

I'll really appreciate your help.

user2924482
  • 8,380
  • 23
  • 89
  • 173
  • Possible duplicate of ["Missing context for method declaration" for overridden description method](https://stackoverflow.com/questions/10341408/missing-context-for-method-declaration-for-overridden-description-method) – trungduc Sep 23 '18 at 03:36

1 Answers1

0

This is what I was looking for:

#import <Foundation/Foundation.h>


NS_ROOT_CLASS
@interface MyClass
-(void)printSomthing;
@end

@implementation MyClass

-(void)printSomthing{
    NSLog(@"it work!!!");
}
@end


int main(int argc, char *argv[]) {


    @autoreleasepool {
        [MyClass printSomthing];
    }
}
user2924482
  • 8,380
  • 23
  • 89
  • 173