Thursday 17 July 2014

OBJECTIVE-C keywords

OBJECTIVE-C keywords

OBJECTIVE-C keywords


Objective-C is a superset of C language, so program written in c and C++ should compile as objective-c. It provides some additional keywords, to avoid conflict with keywords in other language it uses ‘@’ at the beginning of keyword. These keyword are called Compiler Directives.

Directives used to declare and define classes, categories and protocols:
  • @interface used to declare of class or interface.
  •                                 
  •  @implementation used to define a class or category.
  •  @protocol used to declare a formal protocol.
  • @end ends the declaration, definition, category or protocol.

  • Directive used to specify the visibility of the instance. Default is @protected.
  • @private Limits the scope of an instance variable to the class that declares it.
  • @protected Limits instance variable scope to declaring and inheriting classes.
  • @public Removes restrictions on the scope of instance variables.
  • Exception handling directives.
  • @try Defines a block within which exceptions can be thrown.
  • @throw Throws an exception object.
  • @catch Catches an exception thrown within the preceding @try block.
  • @finally A block of code that is executed whether exceptions were thrown or not in a @try block.
  • Directive used for particular purpose.
  • @class Declares the names of classes defined elsewhere.
  • @selector(method_name) It returns the compiled selector that identifies method_name.
  • @protocol(protocol_name) Returns the protocol_name protocol (an instance of the Protocol class). (@protocol is also valid without (protocol_name) for forward
  • declarations.)
  • @encode(type_spec) Yields a character string that encodes the type structure of type_spec.
  • @"string" Defines a constant NSString object in the current module and
  • initializes the object with the specified 7-bit ASCII-encoded string.
  • @"string1" @"string2" ...
  • @"stringN" Defines a constant NSString object in the currentmodule. The string
  • created is the result of concatenating the strings specified in the two
  • directives.
  • @synchronized() Defines a block of code that must be executed only by one thread
  • at a time.

No comments:

Post a Comment

Please comment here...

203 Favorite JavaScript Utilities

https://1loc.dev/