Search Your Question

What is multiplier and ratio in auto layout in ios?

Ans :


Difference between Multiplier and Ratio : 

There is not any difference. Both are using for same purpose.

The Aspect Ratio is really just a convenient way to express the Multiplier when working in Interface Builder. It effectively gets "converted" to a multiplier.

You can confirm this while debugging by inspecting the constraint's .multiplier property. If you set a view's width to 60, and multiplier to 1:2 (resulting in an auto-layout height of 120), the actual value of .multiplier will be 0.5.

So, in my view, it depends on what feels more natural.

If I want a view to be 90% of the width of another view, I am much more likely to set the Multiplier to 0.9 --- which gives the exact same result as setting it to 9:10.

However, if I want a view to maintain an aspect ration of, say, 3-to-2, I am much more likely to set the Multiplier to 3:2 rather than 1.5.

Using a ratio can also be convenient when you have "non-simple" values. That is, it's easy to understand that a ratio of 3:2 is the same as 1.5. But what if I have an image with native size of 281 x 60, and I want to use those values to maintain ratio? 281:60 is easier to understand than .multiplier = 4.68333339691162.

And, while they are interchangeable, it is probably a bit more intuitive to use Ratio when constraining an object to itself - e.g. I want my view's width to be 2 x its own height, so 2:1 - and using Multiplier when constraining one object to another - e.g. I want my view's width to be 75% of the width of its superview, so 0.75.

Difference between nil, NIL and null

Ans : 

The difference is that while
NULL represents zero for any pointer,
nil is specific to objects (e.g., id) and
Nil is specific to class pointers.


Nil,Null and nil are used with below
1> Nil for Objective c Class
2> nil for Objective c object
3> Null for C pointer
Example:
1>Class A=Nil;
2>NSString strName=nil;
3>char *pointerChar = NULL;




OOPS Concept in iOS

Ans :  OOPS Concepts are mostly same in all language. Their working are same but conditions are different.

1.      Inheritance : It allows a class to be defined that has a certain set of characteristics(methods and variables) and then other classes to be created which are derived from that class. The derived class inherits all of the features of the parent class and typically then adds some features of its own.

2.      Encapsulation : That binds data and functions together and keeps both safe from outside interference and misuse. Data encapsulation’s benefit of data hiding.

Data encapsulation is a mechanism of bundling the data and the functions that use them.

Data abstraction is a mechanism of exposing only the interface and hiding the implementation details from the user.


3. Polymorphism : Difference process depends on type. The method to be invoked is determined at runtime based on the type of the object. It is like override and overload.

Override : Different class, same method name with signature. It is also called runtime or dynamic polymorphism.

Overload : Same class, method name same with Different parameter. It is also called compile-time or static polymorphism. 


‌Which method is called first when app start?

Ans :

According to apple doc,


  • (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
gets called before
  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

Why array method containObject has id as parameter in ios?

Ans : id is a generic type. This means that the compiler will expect any object type there, and will not enforce restrictions. It can be useful if you're expecting to use more than one class of objects there. So you can add anything of type id to an NSArray.

So array method containObject has id type as parameter.

- (BOOL)containsObject:(ObjectType)anObject;

Usage :

bool bVal = [arr containObject:@5];