Important Concept Need to Know
Property:
Properties ensure that the instance variable of the class can be accessed outside the class. Properties begin with @property, which is a keyword
=> Properties is followed with access specifiers, which are nonatomic or atomic, readwrite or readonly and strong, unsafe_unretained or weak.
=> This varies based on the type of the variable. For any pointer type, we can use strong, unsafe_unretained or weak. Similarly for other types we can use readwrite or readonly.
What is Keyword Atomic and NonAtomic in Objective-C ?
Atomic Keyword will ensure that a whole value is always returned from the getter or set by the setter, regardless of setter activity on any other thread.
=> Properties are atomic by default .
=> Atomic Keyword is Thread Safe.
=> That is, if thread A is in the middle of the getter while thread B calls the setter, an actual viable value -- an autoreleased object, most likely -- will be returned to the caller in A.
In nonatomic, no such guarantees are made. Thus, nonatomic is considerably faster than "atomic". NonAtomic Keyword does not guarantees about thread safety.
=> If thread A is calling the getter simultaneously with thread B and C calling the setter with different values, thread A may get any one of the three values returned -- the one prior to any setters being called or either of the values passed into the setters in B and C. Likewise, the object may end up with the value from B or C, no way to tell.
=> Properties is followed with access specifiers, which are nonatomic or atomic, readwrite or readonly and strong, unsafe_unretained or weak.
=> This varies based on the type of the variable. For any pointer type, we can use strong, unsafe_unretained or weak. Similarly for other types we can use readwrite or readonly.
What is Keyword Atomic and NonAtomic in Objective-C ?
Atomic Keyword will ensure that a whole value is always returned from the getter or set by the setter, regardless of setter activity on any other thread.
=> Properties are atomic by default .
=> Atomic Keyword is Thread Safe.
=> That is, if thread A is in the middle of the getter while thread B calls the setter, an actual viable value -- an autoreleased object, most likely -- will be returned to the caller in A.
In nonatomic, no such guarantees are made. Thus, nonatomic is considerably faster than "atomic". NonAtomic Keyword does not guarantees about thread safety.
=> If thread A is calling the getter simultaneously with thread B and C calling the setter with different values, thread A may get any one of the three values returned -- the one prior to any setters being called or either of the values passed into the setters in B and C. Likewise, the object may end up with the value from B or C, no way to tell.
What is NSSet ?
An NSSet object represents a static, unordered collection of distinct objects. NSSet is immutable, so you cannot add or remove elements from a set after it’s been created. You can, however, alter mutable objects that are contained in the set.
An NSSet can be created through the setWithObjects: class method, which accepts a nil-terminated list of objects.
An NSSet instance can record any kind of Objective-C object, and it does not have to be homogeneous.
What is NSArray and NSMutableArray ?
NSArray and its subclass NSMutableArray manage ordered collections of objects called arrays. NSArray creates static arrays, and NSMutableArray creates dynamic arrays. You can use arrays when you need an ordered collection of objects.
What is Synchronization ?
Synchronization is defined as a mechanism which ensures that two or more concurrent processes or threads do not simultaneously execute some particular program segment known as mutual exclusion. When one thread starts executing the critical section (serialized segment of the program) the other thread should wait until the first thread finishes.
If proper synchronization techniques are not applied, it may cause a race condition where, the values of variables may be unpredictable and vary depending on the timings of context switches of the processes or threads.
An NSSet can be created through the setWithObjects: class method, which accepts a nil-terminated list of objects.
An NSSet instance can record any kind of Objective-C object, and it does not have to be homogeneous.
What is NSArray and NSMutableArray ?
NSArray and its subclass NSMutableArray manage ordered collections of objects called arrays. NSArray creates static arrays, and NSMutableArray creates dynamic arrays. You can use arrays when you need an ordered collection of objects.
What is Synchronization ?
Synchronization is defined as a mechanism which ensures that two or more concurrent processes or threads do not simultaneously execute some particular program segment known as mutual exclusion. When one thread starts executing the critical section (serialized segment of the program) the other thread should wait until the first thread finishes.
If proper synchronization techniques are not applied, it may cause a race condition where, the values of variables may be unpredictable and vary depending on the timings of context switches of the processes or threads.
Define NSThread ?
An NSThread object controls a thread of execution.
Threads are especially useful when you need to perform a lengthy task, but don’t want it to block the
execution of the rest of the application. In particular, you can use threads to avoid blocking the main thread of the application, which handles user interface and event-related actions. Threads can also be used to divide a large job into several smaller jobs, which can lead to performance increases on multi- core computers.
What is Retain Count or Reference Counting?
Retain Count is the term which is related to the Manual Memory Management .
=> When we create a object, Objective C doesn't really care about the object we have created , the area of memory is claimed for this object and retain count is increased by one.
And whenever we release that object the retain count does go down by one .
=>When the retain count of object reaches zero, Objective C blows that object ( memory occupied by object will be free ) and it will be ready to reclaim that memory for another Object.
What you mean by Asynchronous and GCD in Objective-C ?
Grand Central Dispatch, or GCD for short, is a C API that makes it exceptionally easy to perform asynchronous operations in iOS.
Asynchronous operations are a fundamental part of every iOS app when you want to perform long operations without freezing or blocking the user interface. You can image that if your entire app froze without warning then your users would get quite irritated.
With GCD, you can line up blocks of code in a queue for the system to execute as necessary. These blocks or operations, will be dispatched in the queue to another thread, leaving your main UI thread to continue its tasks.
It’s important to know that GCD will use separate threads for it’s operations but which thread it isn’t important to you. All that matters is that your long running process in a separate thread outside the
main thread where your UI and gestures are running.
What are Blocks :
=> Block is a chunk of code that can be executed at some future time.
=> Blocks are first-class functions, which is a fancy way of saying that Blocks are regular Objective-C objects. Since they’re objects, they can be passed as parameters, returned from methods and functions, and assigned to variables.
=> Blocks are Objective-C objects. Block objects are one type of C-level syntactic and runtime features. Blocks, in addition to executable code in standard C functions, they may also comprise variable bindings to managed (heap) or automatic (stack) memory. Therefore, a block can preserve a set of data that it can use to affect behaviour when executed. They can be added to collections like NSArray or NSDictionary.
Override Getter and Setter Method :
In Objective-C, we use @property to provide managed access to the state of a class. The system provides basic management rules like thread locking and reference retainment. To provide custom access logic,we need to write your own getter and setter methods.
Let’s say that we have a Customer class and its name must always be in upper case. First, we declare the property in the interface:
@interface Customer
{
@property (nonatomic) NSString* name;
}
@end
Next, we do the implementation.
=> Block is a chunk of code that can be executed at some future time.
=> Blocks are first-class functions, which is a fancy way of saying that Blocks are regular Objective-C objects. Since they’re objects, they can be passed as parameters, returned from methods and functions, and assigned to variables.
=> Blocks are Objective-C objects. Block objects are one type of C-level syntactic and runtime features. Blocks, in addition to executable code in standard C functions, they may also comprise variable bindings to managed (heap) or automatic (stack) memory. Therefore, a block can preserve a set of data that it can use to affect behaviour when executed. They can be added to collections like NSArray or NSDictionary.
Override Getter and Setter Method :
In Objective-C, we use @property to provide managed access to the state of a class. The system provides basic management rules like thread locking and reference retainment. To provide custom access logic,we need to write your own getter and setter methods.
Let’s say that we have a Customer class and its name must always be in upper case. First, we declare the property in the interface:
@interface Customer
{
@property (nonatomic) NSString* name;
}
@end
Next, we do the implementation.
@implementation
Customer @synthesize name = _name; //Must do this
//Setter method
- (void) setName:(NSString *)n {
NSLog(@"Setting name to: %@", n);
_name =n;
}
//Getter method
- (NSString*) name {
NSLog(@"Returning name: %@", _name);
return _name;
}
- (void) test {
self.name = @“Prashant ”; NSLog(@"Name is %@", self.name);
}
@end
Here, we are declaring a member variable called _name that is mapped to the name property. The setter method is called setName. The getter method is just name.
Customer @synthesize name = _name; //Must do this
//Setter method
- (void) setName:(NSString *)n {
NSLog(@"Setting name to: %@", n);
_name =n;
}
//Getter method
- (NSString*) name {
NSLog(@"Returning name: %@", _name);
return _name;
}
- (void) test {
self.name = @“Prashant ”; NSLog(@"Name is %@", self.name);
}
@end
Here, we are declaring a member variable called _name that is mapped to the name property. The setter method is called setName. The getter method is just name.
What is a .dSYM and How can we use it?
dSYM files store the debug symbols for your app
Services like crashlytics uses it to replace the symbols in the crash logs with the appropriate methods names so it will be readable and will make sense.
the benefit of using the dSYM is that you don't need to ship your App with it symbols making it harder to reverse engineer it and also reduce your binary size
dSYM files store the debug symbols for your app
Services like crashlytics uses it to replace the symbols in the crash logs with the appropriate methods names so it will be readable and will make sense.
the benefit of using the dSYM is that you don't need to ship your App with it symbols making it harder to reverse engineer it and also reduce your binary size
in order to use it in order to symbolicate the crash log you need to drag the crash log into the device's device logs in the organizer of the machine that compiled the app binary (a machine that stores the dSYM)
No comments:
Post a Comment