ios之最簡(jiǎn)單的程序

1、構(gòu)建學(xué)生對(duì)象并且打印相關(guān)信息
代碼:

    #import <UIKit/UIKit.h>
    #import "AppDelegate.h"
     
    @interface Student : NSObject
    //變量
    @property NSString *name;
    @property int age;
    @property float score;
     
    //method
    -(void)show;
     
    @end
     
    @implementation Student
    -(void)show{
        NSLog(@"%@的年齡是%d成績(jī)是%f", self.name, self.age, self.score);
    }
    @end
    
     
    int main(int argc, char * argv[]) {
        //alloc函數(shù)為隊(duì)形分配內(nèi)存空間,init函數(shù)會(huì)初始化函數(shù)對(duì)象
        Student *stu = [[Student alloc]init];
        stu.name = @"chenyu";
        stu.age = 25;
        stu.score = 100;
        [stu show];
        return 0;
    }

 

2、展示結(jié)果
 
 

 

 
 
作者:chen.yu
深信服三年半工作經(jīng)驗(yàn),目前就職游戲廠商,希望能和大家交流和學(xué)習(xí),
微信公眾號(hào):編程入門(mén)到禿頭 或掃描下面二維碼
零基礎(chǔ)入門(mén)進(jìn)階人工智能(鏈接)