幸运飞艇停吗

ASP源碼.NET源碼PHP源碼JSP源碼JAVA源碼DELPHI源碼PB源碼VC源碼VB源碼Android源碼
當前位置:首頁 >> 網絡編程 >> IOS開發 >> NSObject 底層本質

NSObject 底層本質(1/5)

來源:網絡整理     時間:2018-11-01     關鍵詞:

BENPIANWENZHANGZHUYAOJIESHAOLE" NSObject DICENGBENZHI",ZHUYAOSHEJIDAOFANGMIANDENEIRONG,DUIYUIOSKAIFAGANXINGQUDETONGXUEKEYICANKAOYIXIA: YI、OC ZHUAN C/C++ER、NSObject DUIXIANGNEICUNBUJUSAN、NSObject NEICUNDAXIAOSI、OC DUIXIANGNEICUNBUJUWU、OC DUIXIANGNEICUNDAXIAOYI、OC ZHUAN C/C++OC...

  • 幸运飞艇停吗YI、OC ZHUAN C/C++

  • 幸运飞艇停吗ER、NSObject DUIXIANGNEICUNBUJU

  • SAN、NSObject NEICUNDAXIAO

  • SI、OC DUIXIANGNEICUNBUJU

  • 幸运飞艇停吗WU、OC DUIXIANGNEICUNDAXIAO

一、OC 轉 C/C++

幸运飞艇停吗OC DEDICENGSHITONGGUO C\C++ SHIXIAN,SUOYI OC DAIMABIANYIGUOCHENGYIBANSHIXIANJIANG OC ZHUANWEI C\C++ ,C\C++ JINYIBUZHUANWEIHUIBIANYUYAN,ZUIZHONGZHUANWEIJIQIDAIMA。OC DEDUIXIANGYINGSHEDAO C\C++ ZHUYAODUIYINGDESHIJIEGOUTI,ZHELIMIANDE “JIEGOUTI” BINGFEI C YUYANLIMIANDEJIEGOUTI,ERSHI C++ YUYANLIMIANDEJIEGOUTI,ERQIEZHEGEGAINIANJINXIANZIMIANYISIDEJIEGOUTI。YANGELAIJIANG,QISHIstructGUANJIANZIDINGYIDESHI LEI,GEN class GUANJIANZIDINGYIDELEICHULEMORENFANGWENQUANXIANDEQUBIE,MEIYOUQUBIE。C++ ZHONGDE struct DUI C ZHONGDE struct JINXINGLEKUOCHONG,TAYIJINGBUZAIZHISHIYIGEBAOHANBUTONGSHUJULEIXINGDESHUJUJIEGOULE,TAYIJINGHUOQULETAIDUODEGONGNENG。RU:NENGBAOHANCHENGYUANHANSHU、KEYIJICHENG、KEYISHIXIANDUOTAI。

TONGGUO xcrun MINGLINGKEYIJIANG OC DAIMAZHUANWEIBUTONGPINGTAICPUXIAZHICHIDE C\C++ DAIMA,RU OC DAIMAZHUANWEI arm64 JIAGOU CPU DAIMA,DUIYINGDEMINGLINGWEI:

幸运飞艇停吗xcrun -sdk iphoneos clang -arch arm64 -rewrite-objc OCYUANWENJIAN -o SHUCHUDECPPWENJIAN

二、NSObject 對象本質

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSObject *obj = [[NSObject alloc] init];
    }
    return 0;
}

DIANJIKECHAKANNSObjectDINGYIWEIRUXIA,KEYIKANCHU NSObject LEIZHONGBAOHANLEYIGE isa CHENGYUANBIANLIANG。

@interface NSObject  {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-interface-ivars"
    Class isa  OBJC_ISA_AVAILABILITY;
#pragma clang diagnostic pop
}

SHANGSHUDAIMAJIEZHU xcrun MINGLINGSHENGCHENGDEWENJIANZHONGBAOHANRUXIADAIMA,SHIJISHANGNSObjectDEDINGYIZUIZHONGYESHIZHUANWEIRUXIADAIMA。

//其中 Class 的定義為:typedef struct objc_class *Class; 64位系統中,指針占據 8 個字節
struct NSObject_IMPL {
    Class isa; // 8個字節
};

NSObject *obj = [[NSObject alloc] init];DENEICUNBUJURUXIA。allocXIANGDANGYUWEIWEIYOUCELANSEDEJIEGOUTIKAIPIYIKUAIKONGJIAN,JIEGOUTIZHONGBAOCUNZHU isa CHENGYUAN,isa CHENGYUANDEZHIZHENDEDIZHIXIANGDANGYUJIEGOUTIDIZHIKONGJIAN,CHUSHIHUACHENGGONGHOU,JIEGOUTIDEDIZHIFUZHIGEI obj DUIXIANG,YINCI isa DIZHIHE obj DIZHIXIANGTONG。

三、對象內存大小

3.1 查看內存管大小

相關圖片

相關文章