Classes Functions Objective C

Classes Functions Objective C like most other programming languages are the operational parts of any code. An object might have some properties and some methods. We use methods to better organize and partition our code. Each method has a return type. The default return type is void which means this method doesn’t really return anything. Every method may or may not have some input arguments.

Functions in Objective-C

Functions in Objective C

Similar to Swift, we can add classes in Objective C which would require @interface and @implementation. We can then use these definitions to instantiate our objects.

// declare and define a function in objective-c

@interface SomeClass : BaseClass

@end

// implementation
@imlementation SomeClass

@end

Unlike Swift, Objective C classes must have a base class. You might have seen it when we used UIViewController class. Another root level class is NSObject. This is similar to the founding father of many classes.

If you don’t know what base class you need, then you need NSObject.

Classes in Objective-C

Selector in Classes and Functions in Objective C

In Objective C we use respondsToSelector: to determine at run-time if an object knows how to handle a given message. We will also use the isKindOfClass: in Objective C to learn about the type of an object.

Summary

Classes and Functions are the fundamental aspects of Object Oriented Programming. We user classes as the building block blueprints for creating a variety of objects. Such objects will inherit the functions from the classes and can handle a multitude of tasks.

Interested in learning more in-depth concepts?

If you are interested in learning more about mobile app development, I invite you to join my complete iPhone or Android course(s):

Leave a Comment