NSObject class does not support copying so it has to be implemented in its subclass. If a class MyClass is an NSObject subclass, it needs to implement NSCopying protocol and its copyWithZone method in order for its instance to be copied. The MyClass variables are defined below…
Recent Posts by Luka
Delegates and protocols are very useful concepts in object-oriented programming. These concepts are often used together, especially when a way to provide notifications to unknown objects is needed. Lets assume that we have a couple of classes that need to be notified when an event occurs. On this event occurring, they need to be notified… →
The delegation is a commonly used pattern in object-oriented programming. It is a situation where an object, instead of performing a tasks itself, delegates that task to another, helper object. The helper object is called the delegate. Let’s say there is a main class that wants to delegate the calculation of a sum to another… →
In Objective-C protocols are used to declare a list of methods that are used or may be implemented in any other class. Protocols are declared with the @protocol directive. They have no curly brackets with variables since they cannot have any variables associated with them.
Objective-C supports extensions of classes using categories. Class categories are defined similar as the class itself. The example defines a class MyClass. The header file declares variables myString and myInt, and methods setMyString and setMyInt.
Objective-C is a programming language that allows object-oriented programming at a high level. It is an upgrade to the standard ANSI C programming language. Objective-C extends the standard ANSI C language by providing syntax for defining classes, methods and other constructs extension of classes. Before studying the Objective-C programming language, basic knowledge of programming in… →