Posts

Showing posts with the label Delgate

Copy Vs Mutable Copy in iOS

It's found very confusing for most of the folks, who is not having much experience in Objective-C. Before starting I just to say: Just remember below lines- 1 - copy always creates an immutable copy means you can not modify the object. 2 - mutableCopy always creates a mutable copy  means you can modify the object Here onwards I try to explain copy and mutable copy with some examples: copy: NSArray *obj = [ NSArray arrayWithObjects : @"1" , @"2" , nil ]; NSArray *copyObj = [obj copy ]; NSArray *mutableObj = [obj mutableCopy ]; When you try to see the details of copyObj its clearly shows  __NSArrayI which tells that you can not modify this object Printing description of copyObjy: ( 1, 2 ) Same way  When you try to see the details of mutableObj its clearly shows  __NSArrayM which tells that you can modify this object Printing description of mutableObjy: ( 1, 2 ) As the copyObj is ass...

Swift 3: Protocol Part 1

Introduction: Protocol main and widely used concept in objective c and swift both. So here we will be discussing in swift. We have two parts for a protocol. Part -1, will have basic terminology and concept to understand it and Part 2 and Part 3 will have some more drills in detail about it. The protocol you can think of “Contract” between two bodies. If anyone has acquired it then, that has to follow certain rules to incorporate the action of the contract. Same way Protocol in objective will act in the same way. Protocols define the set of methods, properties, and required pieces of functionality. Any type whoever going to conform it will have to conform first and then implement the requirement. The protocol can be adopted by a class, struct, enum. Any type that fulfilling the requirement of that protocol is said to conform to that protocol. If you conform to the protocol then we need to implement the requirement. We can extend the protocol as well to extend t...