Hello Guys
In this blog, I have declared HomeViewController class and explained how to implement methods in class.
HOMEVIEWCONROLLER.H
#import <UIKit/UIKit.h>
@interface HomeViewController : UIViewController
// With the help of interface you can declare a class of UIViewController.HomeViewController is the derived class of UIViewController
{
NSString *name;
// You can declare IBOutlets as well as Global objects here.
}
(void)displayName;
// I am creating a function where we can display our name.
@end
Now we will implement HomeViewContoller.m file.
@implementation HomeViewController
/*This method is inbuild method which is use to initialize the class from xib. */
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
return self;
}
//Inbulid method. But different from above. This method is called every time you load the xib in the your application.
- (void)viewDidLoad
{
[super viewDidLoad];
//This functions calls the viewDid load of the super class. i.e (UIViewController).
name=@Tushar;
[self displayName];// This our function which is called in view Did Load.
}
-(void)displayName
{ NSLog(@The name is %@,name);
// After calling the method we will get the name is our
}
0 Comment(s)