//
// 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
转载于:https://my.oschina.net/u/2319073/blog/514336