OC高效率52:(一)瞭解OC起源

//
//  ViewController.m
//  OC高效率52之瞭解OC起源
//
//  Created by Zoujie on 15/10/8.
//  Copyright © 2015年 Zoujie. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //    第一條OC語言的起源
    
#pragma mrak 要點
//    OC爲C語言添加了面向對象的特性,是其超集。理解C語言的核心概念有助於寫好OC程序。尤爲內存模型和指針
    
    //    使用"消息結構"(messaging structure)而非"函數調用"(function calling)
   
    //    Message (OC)
    //    Object *obj = [Object new];
    //    [obj performWith:parameter1 and:parameter2];
    
    //    Function calling (C++)
    //    Object *obj = [new Object];
    //    obj ->perform(parameter1,parameter2);

#pragma mark 關鍵區別
//    1.使用消息結構的語言,其運行時所應執行的代碼由運行環境來決定; runtime componet
//    2.使用函數調用的語言,則由編譯器決定;compile time
    
    NSString *someString = @"The String";//此變量指向NSString 的指針
    NSString *anotherString = someString;
    
//    對象所佔內存老是分配在堆空間中,而毫不會分配在 棧 上。
//    有時會遇到定義不含*的變量,他們可能使用 棧空間 這些變量不是OC對象 ,好比CGRect;於建立結構體相比,建立對象還須要額外開銷;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
相關文章
相關標籤/搜索