<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>objc on prometheus</title><link>https://new.halfrost.com/zh/categories/objc/</link><description>Recent content in objc on prometheus</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><copyright>halfrost</copyright><lastBuildDate>Sun, 30 Oct 2016 17:11:38 +0000</lastBuildDate><atom:link href="https://new.halfrost.com/zh/categories/objc/index.xml" rel="self" type="application/rss+xml"/><item><title>Objc 对象的今生今世</title><link>https://new.halfrost.com/zh/objc_life/</link><pubDate>Sun, 30 Oct 2016 17:11:38 +0000</pubDate><guid>https://new.halfrost.com/zh/objc_life/</guid><description>前言 在面向对象编程中，我们每天都在创建对象，用对象描述着整个世界，然而对象是如何从孕育到销毁的呢？
目录 1.孕育对象 2.对象的出生 3.对象的成长 4.对象的销毁 5.总结 一.孕育对象 每天开发我们都在alloc对象，而alloc方法做了些什么呢？
+ (id)alloc { return _objc_rootAlloc(self); } 所有对象alloc都会调用这个root的方法
id _objc_rootAlloc(Class cls) { return callAlloc(cls, false/*checkNil*/, true/*allocWithZone*/); } 这个方法又会去调用callAlloc方法
static ALWAYS_INLINE id callAlloc(Class cls, bool checkNil, bool allocWithZone=false) { if (checkNil &amp;amp;&amp;amp; !cls) return nil; #if __OBJC2__  if (! cls-&amp;gt;ISA()-&amp;gt;hasCustomAWZ()) { // No alloc/allocWithZone implementation. Go straight to the allocator.  // fixme store hasCustomAWZ in the non-meta class and  // add it to canAllocFast&amp;#39;s summary  if (cls-&amp;gt;canAllocFast()) { // No ctors, raw isa, etc.</description></item></channel></rss>