Skip to content

A repository for showcasing my knowledge of the Objective-C programming language, and continuing to learn the language.

License

Notifications You must be signed in to change notification settings

seanpm2001/Learn-Objective-C

Repository files navigation


/Objective-C-Logo.png

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

  1. Objective-C is a language by Apple Inc.

  2. Objective-C uses the *.m *.mm and *.h file extensions

  3. Objective-C is a semicolon and curly bracket language

  4. No other knowledge of the Objective-C++ programming language.