`

How to develpe Object-C on Ubuntu

 
阅读更多

1) Install the GNU Objective-C compiler:

sudo apt-get install gobjc






2) Write a quick bit of test code:

// hello.m
#import <objc/Object.h>
#import <stdio.h>

@interface Number: Object
{
@public
    int number;
    
}
- (void)printNum;

@end

@implementation Number: Object

- (void)printNum
{
    printf("%d\n", number);
}

@end

int main(void)
{
    Number *myNumber = [Number new]; // equal to [[Number alloc] init]
    myNumber->number = 6;
    [myNumber printNum];
    return 0;
}
















3) Compile it:

gcc -o hello hello.m -Wall -lobjc






4) Run it...!

./hello 












分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics