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

來源:互聯網
上載者:User

標籤:

////  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


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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.