How create function in Objective-C

Discussion in 'Mac Programming' started by Filini, Aug 24, 2009.

  1. Filini macrumors newbie

    Filini

    Joined:
    Jan 17, 2009
    #1
    Hi All, I have simple program in C:
    Code:
    #include <stdio.h>		
    
    void myprint();
    
    main()							
    {						
     myprint();   	
    }
    
    void myprint()
    {
    printf("Hello\n");	
    }
    
    How I can do it in Objective-C???
    I can't understand, how convert this peace of code in Objective-C

    Thx for help
     
  2. `lowell` macrumors newbie

    Joined:
    Aug 20, 2009
    Location:
    San Diego
    #2
    Code:
    #import <Foundation/Foundation.h>
    
    @class Filini;
    
    int main (int argc, const char * argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    
        [Filini myPrint];
        [pool drain];
        return 0;
    }
    
    @interface Filini : NSObject {}
    + (void) myPrint;
    @end
    
    @implementation Filini
    
    + (void) myPrint {
    	NSLog(@"Hello\n");
    }
    
    @end
    
    i've been drinking.
     
  3. `lowell` macrumors newbie

    Joined:
    Aug 20, 2009
    Location:
    San Diego
    #4
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #5
    it's a guide on this site. Why not correct it?

    -Lee
     
  5. Filini thread starter macrumors newbie

    Filini

    Joined:
    Jan 17, 2009

Share This Page