Objective-C is an object-oriented general-purpose programming language which provides extra style messaging to the C programming language. The Objective-C programming is mainly for the iOS operating system and API of iOS such as Cocoa and Cocoa touches. This programming language is a superset of C, and it calls the code of C++ programming language. This cheat sheet will help you through simple and practical approach while learning Objective-C programming language. Whichever service is in high demand, you can get freelance services for the same.
Basic Syntax of Objective-C
An Objective-C program consists of a single token and various tokens. The token may be symbols, identifier, and keywords. Following are the basic syntax of the objective- C programming language.
NSLog(@”Hello, World! \n”);
Data Types in Objective-C
The data type is used to an extensive system which is useful for declaring variables, and function of the programming language. The type of the variable decides how much space you require for the storage. Following are the types of Objective-C.
- Basic Types: There are two basic types 1) integer types 2) floating point types.
- Enumerated Types: They are used to define variables that can only assign definite discrete integer values throughout the program.
- Void Type: This data type shows the no value is available.
- Derived Types: The derived types have five categories 1) Array types 2) Structure Types 3) Function Types 4) Union Type
Variable in Objective-C
Variables in Objective-C have a specific type which finds the size and layout of the variables memory. The variables start with a letter or an underscore. Objective-C is the case sensitive, so the upper and lower case letter is different. Following are the types of the variables in Objective-C
Operators in Objective-C
Operators are the important component of the programming language because these operators tell the compiler to perform particular mathematical and logical manipulation. Following are the types of the Operators.
- Arithmetic Operators
- Logical Operators
- Bitwise Operators
- Relational Operators
- Assignment Operators
- Misc Operators
Array in Objective-C
In an Objective-C array is the collection of similar type of data types which can store sequentially in a fixed size.
Syntax for declaration of array
type arrayName [ arraySize ];
Initialization of array:
char name ;
Pointers in Objective-C
A pointer is a variable which stores the address of another variable. In Objective-C pointer is declared using a symbol (*).
Syntax of Pointers
String in Objective-C
The concept of the string in an Objective-C programming language is using NSString, and its subclass NSMutableString provides different ways for creating string objects.
Syntax for string
NSString *Name = @”Kitty”;
Function in Objective-C
The function is the block of statements that combines to perform the task. Every Objective-C program has C function that is main() function. The declaration includes the terms of a function name, return type, and parameters. Whichever service is in high demand, you can get freelance services for the same. Following are the syntax of the function
(return_type) method_name:( argumentType1 )argumentName1
joiningArgument2:( argumentType2 )argumentName2 …
joiningArgumentn:( argumentTypen )argumentNamen
the body of the function
typedef in Objective-C
The keyword typedef in Objective-C is used to give a new name. Following is the syntax for typedef keyword.
typedef unsigned char BYTE
Type Casting is the technique which converts a variable from one data type to another data type. For ex, if you want to store a double value into float then that time Type Cast performs an important role.
Syntax for type casting
Inheritance in Objective-C
Inheritance is one of the important concepts of object-oriented programming language. Using the inheritance concept, you can derive a new class from the existing class. It allows the developer to reuse the code functionality and fasten the implementation time.
@interface derived-class: base-class
Polymorphism in Objective-C
The term polymorphism is applied when there is a hierarchy of classes, and there is inheritance. In Objective-C, the polymorphism concept calls the member function, and another function gets executed according to the type of objects that invokes the function.
Data Encapsulation in Objective-C
Encapsulation is one of the important Object-Oriented Programming concepts that bind together the data and functions. The data encapsulation also leads to the important OOP concept that is data hiding. The Objective-C supports the properties of data hiding and encapsulation through the creation of user-defined types such as classes. The private method in the encapsulation is writing with the help of an extension.
@interface Adder : NSObject
It is the article on Objective-C programming cheat sheet. This cheat sheet will help you to understand basic and advance the concept of Objective-C programming language.
This article is about objective c programming cheat sheet. Whichever service is in high demand, you can get freelance services for the same.