T
T
timofej33412020-04-23 18:18:21
Objective-C
timofej3341, 2020-04-23 18:18:21

How to call a method in Objective c?

For some reason, the method in Objective c stubbornly refuses to be called. He wrote in different ways, took examples and all in vain.

#import <Foundation/Foundation.h>
@interface Greeting : NSObject
- (void)sayHello;
@end
@implementation Greeting
- (void)sayHello {
    NSLog(@"Hello, World!");
}
@end
int main(){
    Greeting *v= [[Greeting alloc]init];
    [v sayHello];
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question