Steps involved in the Creation of a new class in Objective -C
For creating a new class in objective -c, we need to declare an interface and then define its implementation. In Objective -C declaration and Definition are written in two separate files. The Declaration in the .h file and the implementation in the .m file. Both declarations and the definition parts use compiler directives. Compiler predicates can be recognize by the Objective-C complier by seeing the @ symbol. @interface notify the compiler that it is a Definition and @implementation will notify the compiler it is a implementation part.
Basic Class Declaration
Now iam going to create a class with a class name MyClassName as a subclass of MyParentClassName.
In the definition part of interface will be look like this.
After the interface declaration we need to add the implementation part of the interface.
After that we need to add some methods to the class. For that we need to define the method name in @interface declaration[if it is need to access to the externel world. otherwise we can define the method inside the implementation.] Your class interface will look like this
Ater that we need to write the implementation part of the method in the .m file. It will look like this..
stay tuned… will be back with a new lesson ……
No comments:
Post a Comment