Objective-C

1. How many different annotations available in Objective-C ?

  • _Null_unspecified, which bridges to a Swift implicitly unwrapped optional. This is the default.
  • _Nonnull, the value won’t be nil it bridges to a regular reference.
  • _Nullable the value can be nil, it bridges to an optional.
  • _Null_resettable the value can never be nil, when read but you can set it to know to reset it. This is only apply property.

Objective-C

2. Explain method Swizzling

Method Swizzling is a well known practice in Objective-C and in other languages that support dynamic method dispatching. Through swizzling, the implementation of a method can be replaced with a different one at runtime, by changing the mapping between a specific #selector(method) and the function that contains its implementation. To use method swizzling with your Swift classes there are two requirements that you must comply with: The class containing the methods to be swizzled must extend NSObject The methods you want to swizzle must have the dynamic attribute

Explain how an autorelease pool works The concept of an autorelease pool is simple, whenever an object instance is marked as autoreleased (for example NSString* str = [[[NSString alloc] initWithString:@"hello"] autorelease];), it will have a retain count of +1 at that moment in time, but at the end of the run loop, the pool is drained, and any object marked autorelease then has its retain count decremented. It's a way of keeping an object around while you prepare whatever will retain it for itself.

results matching ""

    No results matching ""