| Start |
|---|
| Conforming to protocol You can add protocols to standard classes to extends their functionality: where |
| Simple Category Interface and implementation of a simple category on NSArray, named Filter, with a single method that filters numbers. It is good practice to add a prefix ( |
| Declaring a class method Header file and implementation |
| Adding a property with a category Properties can be added with categories using associated objects, a feature of the Objective-C runtime. Note that the property declaration of |
| Create a Category on XCode Categories provide the ability to add some extra functionality to an object without subclassing or changing the actual object. For example we want to set some custom fonts.
Let's create a category that add functionality to Declare the Category Method :- Click "UIFont+CustomFonts.h" to view the new category's header file. Add the following code to the interface to declare the method. Now Implement the Category Method:- Click "UIFont+CustomFonts.m" to view the category's implementation file. Add the following code to create a method that will set ProductSansRegular Font. Import your category Now set the Label font SyntaxRemarksTo avoid method name clashes, it is recommended to use prefixes (like |
Read Article
https://develop.horje.com/learn/1434/reference