Learning Objective-C
I hardly know anything about the Objective-C programming language. This document will go over all of my knowledge of the Objective-C programming language.
Hello World in Objective-C
This is an example of a Hello World program in Objective-C, taken from TutorialsPoint this language is complicated, I don't understand it, and I have no way of testing it.
#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
- (void)sampleMethod;
@end
@implementation SampleClass
- (void)sampleMethod {
NSLog(@"Hello, World! \n");
}
@end
int main() {
/* my first program in Objective-C */
SampleClass *sampleClass = [[SampleClass alloc]init];
[sampleClass sampleMethod];
return 0;
}
/!\ This example has not been tested yet, and may not work
Comments in Objective-C
Comments in Objective-C are identical to those of comments in C, C++, etc.
// This is a single line comment
/* This is
a multi-li
ne comment
*/
/!\ This example has not been tested yet, and may not work
Other knowledge of the Objective-C programming language
-
Objective-C is a language by Apple Inc.
-
Objective-C uses the
*.m
*.mm
and*.h
file extensions -
Objective-C is a semicolon and curly bracket language
-
No other knowledge of the Objective-C++ programming language.