Corporation it was designed to enable the powerful feature of objective-oriented programming it works as a powerfull set of extension to the c-language.
1. objective C takes the best feature from c and small talk it is easy to learn and has full objective oriented capabilities Apple has selected objective c has primary programming language for an MVC and iphone.
2. It is a power full language easy to learn and objective-oriented version of C it provides dynamic binding.
3. Easy to understand code and when the organized language that why objective c is selected for coco of the framework.
If you want to become a ios Certified Specialist, then visit Mindmajix - A Global online training platform: “Online ios Development Training”. This course will help you to achieve excellence in this domain
Properties:
Keywords:
Objective c has same additional keywords to avoid conflict with a keyword in other languages it uses @ at the being of the keywords
Access specifies:
Exception handling directives:
Directives used for the particular purpose:
Keywords for memory management:
Some other keywords:
Preprocessor directives:
#import, #define
A class is nothing but a collection of variables and function it is a blueprint for creating objects
Note:- NS object is the main base class for all objects
.h file:-
#import
@interface a: other class name
{
//variable declaration
Int x;
Float y;
Nesting *str”;
}
//property declaration
@property (non atomic , retain)nesting*str”;
//method declaration
Void addition ();
Void subtraction();
@end.
.m file:-
@implementation A
Void addition ()
{
}
Void subtraction ()
{
}
@end.
Properties
objective c 2.0 introduces a new syntax to declare instance variables as properties.
1) Atomic:
In objective c by default property attribute is atomic in atomic multiple threads are created for setting and getting the values for creating thread extra code will be generated and it leads to performance issue
2) Non-atomic:
By using this attribute we tell the compiler that it doesn’t to generate extra code for thread creation. It is a thread safety.
If we don’t specify non-atomic the compiler will generate extra code, and property can be accessed from single threads with improves to performance.
3) Read-only:
This attribute tells the compiler that the property can declare be read but not be said the compiler will be only generated.
4) Retain:
This specifies that you are instead inputting ownership claim on the object if the caller releases this object it does not deallocate because you retained it.
5) Copy:
This attribute creates a copy of the object can we called the setter method, and then you become an owner of the new object.
1) Setter methods: This is used per setting a value to the property
2) Getter method: This is used per getting a value to the property
3) @synthesize: If you use this directive in a program for the property then no need to write accessory methods to the property.
Syntax:- @synthesize str;
Realizing a property:
Syntax:- [str release];
These statements are written in the deal loc method.
Frequently Asked iPhone Interview Questions & Answers
Subroutines are generally called methods in objective c they are divided into 2 types
1. Class methods
2. Instance methods
→ A class method is noted with a + in declaration and documentation.
→ An instance method is marked within (-) sign
→ Every method can be called by class or instance of the class
Syntax of objective C methods:
+ (return type) method name———–instant class method
_ (return type)method name————instance method.
Eg:- .hfile:-
#import
@interface auto view controller . UI view controller
{
}
//instance methods
– (void) addition;
– (void) subtraction : (int)a b : (int)b;
//class methods
+ (void) divisions;
+ (void) multiplication;
@end
.m file:-
#import “auto view Controller.h”
@implementation auto view controller
//instance methods
– (void) addition
{
//calling instance method
[Self Subtraction: 10 B: 20]
//Calling Class method
[Auto view controller division];
}
– (void) subtraction: (int)a b:int)b
{
}
//class method
+ (void) division
{
}
+ (void)multiplication
{
}
@end
Note:-
àHow to print an message in the command prompt
printf (“hello”);
NSLog(@”type message in here”);
àHow to print objects in the command prompt
printf (“%d %f”, a, b);
NSLog (@”%d%@”,a, any object);
Categories:
Eg:–
.h file:-
#import
@ Interface NS object (algebra)
– (void) addition;
– (void)subtraction;
@end
.m file:-
#import NS object + algebra .h”
@implementation NS object(algebra)
-(void)addition
{
}
-(void)subtraction
{
}
@end
→ Unlike subclass category can’t add instance method.
→ You can, however, use category to over side existing methods in subclasses.
Note: When we make changes a class using a category it affects all instances of that class throughout the application.
Id: Id is a general type assigning any type of object regards less of class by default all c functions return integer type in objective c it returns id type
Ex:-
NS string *str = @ “Hai”; // str is string object
Id str = str;
// id as return type
-(id)addition
{
Return some obj;
}
// id as argument
– (void)addition;(id)str bLid)str2
{
}
Its difference between function call’s and messages is that in a function call which are arguments are join to gather on the compilation code but in case of messages not link until a program is run [ linking and runtime]
Ex:- void view did load
{
[Self addition];
}
Binding on runtime so this is calling as dynamic binding it
It is not a compile-time error
-(void)additions;
NOTE:
The extra method that is involved to respond a message can only determine at runtime.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
IOS Development Training | Dec 24 to Jan 08 | View Details |
IOS Development Training | Dec 28 to Jan 12 | View Details |
IOS Development Training | Dec 31 to Jan 15 | View Details |
IOS Development Training | Jan 04 to Jan 19 | View Details |
Technical Content Writer