Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Objective-C

< >

Objective-C is a programming language created in 1984 by Brad Cox.

#33on PLDB 40Years Old 536kRepos
Homepage · REPL · Wikipedia · Subreddit · Docs

Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. It was the main programming language used by Apple for the OS X and iOS operating systems, and their respective application programming interfaces (APIs) Cocoa and Cocoa Touch prior to the introduction of Swift. The programming language Objective-C was originally developed in the early 1980s. Read more on Wikipedia...


Example from Riju:
#import <Foundation/Foundation.h> int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Hello, world!"); [pool drain]; return 0; }
Example from hello-world:
/* Build on OS X: clang -framework Foundation -fobjc-arc objc.m -o objc Build on Linux with GNUstep: clang `gnustep-config --objc-flags` `gnustep-config --base-libs` -fobjc-nonfragile-abi -fobjc-arc objc.m -o objc */ #import <Foundation/Foundation.h> int main(void) { NSLog(@"Hello World"); }
/* Hello World in Objective-C. ** Since the standard implementation is identical to K&R C, ** a version that says hello to a set of people passed on ** the command line is shown here. */ #include <stdio.h> #include <objpak.h> int main(int argc,char **argv) { id set = [Set new]; argv++;while (--argc) [set add:[String str:*argv++]]; [set do:{ :each | printf("hello, %s!\n",[each str]); }]; return 0; }
Example from Linguist:
#import "Foo.h" @implementation Foo @end
Example from Wikipedia:
-(void) firstLabel: (int)param1 secondLabel: (int)param2;
Objective-C Keywords
auto break case char const continue default do double else enum extern float for goto if inline int long register restrict return short signed sizeof static struct switch typedef union unsigned void volatile while _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in inout nil NO NULL oneway out Protocol SEL self Super YES @ @interface @end @implementation @protocol @class @public @protected @private @property @try @throw @catch() @finally @synthesize @dynamic @selector atomic nonatomic retain

Language features

Feature Supported Example Token
Standard Library NSLog(@"Hello, World!");
Explicit Standard Library #include
Conditionals
Switch Statements
Constants
While Loops
MultiLine Comments /* A comment */ /* */
Print() Debugging printf
Comments // A comment
Message Passing
Line Comments // A comment //
Interfaces @protocol Printing -(void) print; @end
File Imports // #import ensures that a file is only ever included once so that you never have a problem with recursive includes. #import #include #include
Constructors
Pointers
Single Dispatch
Strings "hello world" "
Case Insensitive Identifiers X
Semantic Indentation X
Operator Overloading X
Garbage Collection X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v164.7.0