Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Classes and implementing methods in Objective C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 60
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: