//
// main.m
// L02HelloObjC
//
// Created by JinXin on 15/11/25.
// Copyright © 2015年 JinXin. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
// 类的声名部分
@interface Hello : NSObject{
int num;
}
-(void)sayHello;
@end
// 类的实现部分
@implementation Hello
-(instancetype)init{
self = [super init]; // 初始化父类
if (self) {
num = ;
}
return self;
}
-(void)sayHello{
NSLog(@"hello oc class");
NSLog(@"num is %d",num);
}
@end
int main(int argc, char * argv[]) {
Hello *h = [[Hello alloc]init]; // 创建类对象
[h sayHello]; // 调用类方法
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}