剖析【OC】中深復(fù)制與淺復(fù)制

在OC編程中桃熄,常常會用到對對象的復(fù)制,然后操作副本對象恨锚。然而對與應(yīng)該選擇何種對象復(fù)制的方式宇驾,復(fù)制后副本對象操作會不會影響原始對象等問題,我們往往沒有過多考慮猴伶,而是憑借經(jīng)驗(yàn)在編碼课舍。接下來就對OC中對象復(fù)制機(jī)制進(jìn)行剖析,通過對復(fù)制機(jī)制的研究可以在編碼中對對象的復(fù)制更加游刃有余他挎。

首先筝尾,在OC中復(fù)制分為深復(fù)制與淺復(fù)制,一個比較認(rèn)可的定義是:

深復(fù)制:復(fù)制對象引用與對象本身办桨。
淺復(fù)制:只復(fù)制對象引用筹淫。


那么哪些操作才是淺復(fù)制,哪些操作是深復(fù)制呢撞?

所有的對象間賦值操作都是淺復(fù)制损姜,僅僅復(fù)制了引用饰剥。如 CopyStr = Str1,這里CopyStr和Str1指向的同一內(nèi)存地址摧阅,改變兩者之間任何一個值汰蓉,另一個都會隨之改變。

試?yán)a:

void assignTest()
{
    printf("-----Assign Test-----\n\n");
    
    NSString *str1 = @"Hello";
    NSString *str2 = str1;
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [NSMutableString stringWithString:@"Hello"];
    NSMutableString *str4 = str3;
    [str3 appendString:@" World"];
    [str4 appendString:@"!"];
    printf("orignalStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str4 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str3);
    printf("copyStr value address: %p\n",str4);
    printf("orignalStr pointer address: %p\n",&str3);
    printf("copyStr pointer address: %p\n",&str4);
    printf("\n");
    
    NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:@"Hello", nil];
    NSMutableArray *arr2 = arr1;
    [arr1 addObject:@"World"];
    [arr2 addObject:@"!"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
}

輸出結(jié)果:

-----Assign Test-----


orignalStr : Hello
copyStr : Hello
orignalStr value address: 0x100002060
copyStr value address: 0x100002060
orignalStr pointer address: 0x7fff5fbff7a8
copyStr pointer address: 0x7fff5fbff7a0


orignalStr : Hello World!
copyStr : Hello World!
orignalStr value address: 0x1002005c0
copyStr value address: 0x1002005c0
orignalStr pointer address: 0x7fff5fbff798
copyStr pointer address: 0x7fff5fbff790


2016-08-22 11:35:20.312 CopyDemo[2046:72936] orignalArray : (
** Hello,**
** World,**
** "!"**
)
2016-08-22 11:35:20.313 CopyDemo[2046:72936] copyArray : (
** Hello,**
** World,**
** "!"**
)
orignalArray value address: 0x100406910
copyArray value address: 0x100406910
orignalArray pointer address: 0x7fff5fbff788
copyArray pointer address: 0x7fff5fbff780


通過上面結(jié)果我們可以看到逸尖,value的地址都是一樣的古沥,而pointer的地址是不一樣的,這就說明了賦值操作是淺復(fù)制娇跟,只是生成兩份對象的引用岩齿,而對象本身還是同一份。原對象值和副本對象的值操作是相互影響的苞俘。


**那么OC中如何實(shí)現(xiàn)深復(fù)制呢盹沈? **

OC中深復(fù)制是通過copy與mutableCopy方法實(shí)現(xiàn)(但不是都能達(dá)到深復(fù)制的目的),通過copy復(fù)制后的副本都是不可變的吃谣,通過mutableCopy復(fù)制后的副本都是可變的乞封。如初始對象為NSString與NSMutableString,通過copy后副本都是NSString岗憋,而通過mutableCopy后都是NSMutableString肃晚。
接下來分兩種情況討論copy與mutableCopy:

初始對象不可變(如NSString、NSArray等)

調(diào)用copy方法也是淺復(fù)制仔戈,等同于直接賦值关串,因?yàn)閺?fù)制過后的副本和原來的對象都是不可變的,所以調(diào)用copy本質(zhì)就是賦值操作监徘,復(fù)制了引用晋修,但是都指向同一內(nèi)存地址。
調(diào)用mutableCopy是深復(fù)制凰盔,副本成為了可變對象墓卦,但是操作副本,對初始對象的值不會產(chǎn)生影響户敬。

試?yán)a:

void constCopyTest()
{
    printf("-----ConstCopy Test-----\n\n");
    
    printf("-NSString Copy-\n");
    NSString *str1 = @"Hello";
    NSString *str2 = [str1 copy];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [str1 mutableCopy];
    [str3 appendString:@" World!"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str3);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str3);
    printf("\n");
    
    printf("-NSArray Copy-\n");
    NSArray *arr1 = [NSArray arrayWithObjects:[NSMutableString stringWithString:@"Hello"], nil];
    NSArray *arr2 = [arr1 copy];
    [[arr1 objectAtIndex:0] appendString:@" World!"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
    
    NSMutableArray *arr3 = [arr1 mutableCopy];
    [arr3 addObject:@"World"];
    [[arr1 objectAtIndex:0] appendString:@" + str1"];
    [[arr3 objectAtIndex:0] appendString:@" + str3"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr3);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr3);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr3);
    printf("\n");
}

輸出結(jié)果:

-----ConstCopy Test-----


-NSString Copy-
orignalStr : Hello
copyStr : Hello
orignalStr value address: 0x100002060
copyStr value address: 0x100002060
orignalStr pointer address: 0x7fff5fbff7a8
copyStr pointer address: 0x7fff5fbff7a0


orignalStr : Hello
copyStr : Hello World!
orignalStr value address: 0x100002060
copyStr value address: 0x1004074d0
orignalStr pointer address: 0x7fff5fbff7a8
copyStr pointer address: 0x7fff5fbff798


-NSArray Copy-
2016-08-22 11:35:20.314 CopyDemo[2046:72936] orignalArray : (
** "Hello World!"**
)
2016-08-22 11:35:20.314 CopyDemo[2046:72936] copyArray : (
** "Hello World!"**
)
orignalArray value address: 0x1001016b0
copyArray value address: 0x1001016b0
orignalArray pointer address: 0x7fff5fbff790
copyArray pointer address: 0x7fff5fbff788


2016-08-22 11:35:20.314 CopyDemo[2046:72936] orignalArray : (
** "Hello World! + str1 + str3"**
)
2016-08-22 11:35:20.314 CopyDemo[2046:72936] copyArray : (
** "Hello World! + str1 + str3",**
** World**
)
orignalArray value address: 0x1001016b0
copyArray value address: 0x100300000
orignalArray pointer address: 0x7fff5fbff790
copyArray pointer address: 0x7fff5fbff780


輸出結(jié)果可以看到落剪,通過copy方法復(fù)制后的副本對象的value地址和原對象是一樣的,所以針對不可變對象是用copy方法是淺復(fù)制尿庐。而mutableCopy方法復(fù)制后忠怖,副本對象的value和pointer地址都和原對象不一樣了,說明mutableCopy方法是深復(fù)制屁倔。

初始對象可變(如NSMutableString脑又、NSMutableArray等)

調(diào)用copy方法是深復(fù)制,因?yàn)檫@里副本是不可變的,所以只考慮初始對象改變问麸。因?yàn)槭巧顝?fù)制往衷,初始對象無論怎么改變,副本的值都是不變的严卖。
調(diào)用mutableCopy也是深復(fù)制席舍,復(fù)制過后,副本與初始對象之間的改變都是獨(dú)立不影響的哮笆,如初始對象str = “example”来颤,str+” append1”,副本str+” append2”稠肘,最終輸出結(jié)果會是初始對象為”example append1”福铅,副本為”example append2”。

試?yán)a:

void mutableCopyTest()
{
    printf("-----MutableCopy Test-----\n\n");
    
    printf("-NSString Copy-\n");
    NSMutableString *str1 = [NSMutableString stringWithString:@"Hello"];
    NSString *str2 = [str1 copy];
    [str1 appendString:@" World"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [str1 mutableCopy];
    [str1 appendString:@" + str1"];
    [str3 appendString:@" + str3"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str3);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str3);
    printf("\n");
    
    printf("-NSArray Copy-\n");
    NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:[NSMutableString stringWithString:@"Hello"], nil];
    NSArray *arr2 = [arr1 copy];
    [[arr1 objectAtIndex:0] appendString:@" World!"];
    [arr1 addObject:@"Word"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
    
    NSMutableArray *arr3 = [arr1 mutableCopy];
    [arr1 addObject:@"+arr1"];
    [arr3 addObject:@"+arr3"];
    [[arr1 objectAtIndex:0] appendString:@" + str1"];
    [[arr3 objectAtIndex:0] appendString:@" + str3"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr3);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr3);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr3);
    printf("\n");
}

輸出結(jié)果:

-----MutableCopy Test-----


-NSString Copy-
orignalStr : Hello World
copyStr : Hello
orignalStr value address: 0x100300080
copyStr value address: 0x6f6c6c654855
orignalStr pointer address: 0x7fff5fbff7a8
copyStr pointer address: 0x7fff5fbff7a0


orignalStr : Hello World + str1
copyStr : Hello World + str3
orignalStr value address: 0x100300080
copyStr value address: 0x100300320
orignalStr pointer address: 0x7fff5fbff7a8
copyStr pointer address: 0x7fff5fbff798


-NSArray Copy-
2016-08-22 11:35:20.314 CopyDemo[2046:72936] orignalArray : (
** "Hello World!",**
** Word**
)
2016-08-22 11:35:20.314 CopyDemo[2046:72936] copyArray : (
** "Hello World!"**
)
orignalArray value address: 0x100300000
copyArray value address: 0x100300b00
orignalArray pointer address: 0x7fff5fbff790
copyArray pointer address: 0x7fff5fbff788


2016-08-22 11:35:20.314 CopyDemo[2046:72936] orignalArray : (
** "Hello World! + str1 + str3",**
** Word,**
** "+arr1"**
)
2016-08-22 11:35:20.314 CopyDemo[2046:72936] copyArray : (
** "Hello World! + str1 + str3",**
** Word,**
** "+arr3"**
)
orignalArray value address: 0x100300000
copyArray value address: 0x100300e40
orignalArray pointer address: 0x7fff5fbff790
copyArray pointer address: 0x7fff5fbff780


通過輸出結(jié)果可以看到项阴,對于可變對象滑黔,調(diào)用copy與mutableCopy方法都是深復(fù)制,因?yàn)楦北镜膙alue和pointer地址都與原對象不同环揽。

注:對于網(wǎng)上某些解釋說NSArray/NSMutableArray NSDictionary/NSMutableDictionary只有淺復(fù)制略荡,這里認(rèn)為對于對象本身來說調(diào)用mutableCopy或?qū)τ诳勺儗ο笳{(diào)用copy都是深復(fù)制,只能說對于數(shù)組和字典這種復(fù)合結(jié)構(gòu)深復(fù)制操作只是作用到外層對象歉胶,內(nèi)部如果還有可變對象汛兜,僅僅就是引用的復(fù)制。(上面的例子中對于數(shù)組的第一個元素的操作可以很清楚的看出來通今。即使是對數(shù)組的深復(fù)制粥谬,然而改變第一個可變字符串,無論是副本數(shù)組還是原數(shù)組的第一個字符串都改變了衡创。)

完整代碼:

//
//  main.m
//  CopyDemo
//
//  Created by Jiao Liu on 6/23/16.
//  Copyright ? 2016 ChangHong. All rights reserved.
//

#import <Foundation/Foundation.h>

void mutableCopyTest()
{
    printf("-----MutableCopy Test-----\n\n");
    
    printf("-NSString Copy-\n");
    NSMutableString *str1 = [NSMutableString stringWithString:@"Hello"];
    NSString *str2 = [str1 copy];
    [str1 appendString:@" World"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [str1 mutableCopy];
    [str1 appendString:@" + str1"];
    [str3 appendString:@" + str3"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str3);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str3);
    printf("\n");
    
    printf("-NSArray Copy-\n");
    NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:[NSMutableString stringWithString:@"Hello"], nil];
    NSArray *arr2 = [arr1 copy];
    [[arr1 objectAtIndex:0] appendString:@" World!"];
    [arr1 addObject:@"Word"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
    
    NSMutableArray *arr3 = [arr1 mutableCopy];
    [arr1 addObject:@"+arr1"];
    [arr3 addObject:@"+arr3"];
    [[arr1 objectAtIndex:0] appendString:@" + str1"];
    [[arr3 objectAtIndex:0] appendString:@" + str3"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr3);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr3);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr3);
    printf("\n");
}

void constCopyTest()
{
    printf("-----ConstCopy Test-----\n\n");
    
    printf("-NSString Copy-\n");
    NSString *str1 = @"Hello";
    NSString *str2 = [str1 copy];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [str1 mutableCopy];
    [str3 appendString:@" World!"];
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str3);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str3);
    printf("\n");
    
    printf("-NSArray Copy-\n");
    NSArray *arr1 = [NSArray arrayWithObjects:[NSMutableString stringWithString:@"Hello"], nil];
    NSArray *arr2 = [arr1 copy];
    [[arr1 objectAtIndex:0] appendString:@" World!"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
    
    NSMutableArray *arr3 = [arr1 mutableCopy];
    [arr3 addObject:@"World"];
    [[arr1 objectAtIndex:0] appendString:@" + str1"];
    [[arr3 objectAtIndex:0] appendString:@" + str3"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr3);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr3);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr3);
    printf("\n");
}

void assignTest()
{
    printf("-----Assign Test-----\n\n");
    
    NSString *str1 = @"Hello";
    NSString *str2 = str1;
    printf("orignalStr : %s\n",[str1 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str2 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str1);
    printf("copyStr value address: %p\n",str2);
    printf("orignalStr pointer address: %p\n",&str1);
    printf("copyStr pointer address: %p\n",&str2);
    printf("\n");
    
    NSMutableString *str3 = [NSMutableString stringWithString:@"Hello"];
    NSMutableString *str4 = str3;
    [str3 appendString:@" World"];
    [str4 appendString:@"!"];
    printf("orignalStr : %s\n",[str3 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("copyStr : %s\n",[str4 cStringUsingEncoding:NSUTF8StringEncoding]);
    printf("orignalStr value address: %p\n",str3);
    printf("copyStr value address: %p\n",str4);
    printf("orignalStr pointer address: %p\n",&str3);
    printf("copyStr pointer address: %p\n",&str4);
    printf("\n");
    
    NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:@"Hello", nil];
    NSMutableArray *arr2 = arr1;
    [arr1 addObject:@"World"];
    [arr2 addObject:@"!"];
    NSLog(@"orignalArray : %@",arr1);
    NSLog(@"copyArray : %@",arr2);
    printf("orignalArray value address: %p\n",arr1);
    printf("copyArray value address: %p\n",arr2);
    printf("orignalArray pointer address: %p\n",&arr1);
    printf("copyArray pointer address: %p\n",&arr2);
    printf("\n");
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        assignTest();
        constCopyTest();
        mutableCopyTest();
    }
    return 0;
}

本文最早發(fā)布于長虹軟服公眾號帝嗡,有興趣的朋友可以去看一下:
剖析【OC】中深復(fù)制與淺復(fù)制

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末晶通,一起剝皮案震驚了整個濱河市璃氢,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌狮辽,老刑警劉巖一也,帶你破解...
    沈念sama閱讀 212,884評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異喉脖,居然都是意外死亡椰苟,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,755評論 3 385
  • 文/潘曉璐 我一進(jìn)店門树叽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來舆蝴,“玉大人,你說我怎么就攤上這事〗嗾蹋” “怎么了层皱?”我有些...
    開封第一講書人閱讀 158,369評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長赠潦。 經(jīng)常有香客問我叫胖,道長,這世上最難降的妖魔是什么她奥? 我笑而不...
    開封第一講書人閱讀 56,799評論 1 285
  • 正文 為了忘掉前任瓮增,我火速辦了婚禮,結(jié)果婚禮上哩俭,老公的妹妹穿的比我還像新娘绷跑。我一直安慰自己,他們只是感情好凡资,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,910評論 6 386
  • 文/花漫 我一把揭開白布你踩。 她就那樣靜靜地躺著,像睡著了一般讳苦。 火紅的嫁衣襯著肌膚如雪带膜。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 50,096評論 1 291
  • 那天鸳谜,我揣著相機(jī)與錄音膝藕,去河邊找鬼。 笑死咐扭,一個胖子當(dāng)著我的面吹牛芭挽,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播蝗肪,決...
    沈念sama閱讀 39,159評論 3 411
  • 文/蒼蘭香墨 我猛地睜開眼袜爪,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了薛闪?” 一聲冷哼從身側(cè)響起辛馆,我...
    開封第一講書人閱讀 37,917評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎豁延,沒想到半個月后昙篙,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,360評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡诱咏,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,673評論 2 327
  • 正文 我和宋清朗相戀三年苔可,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片袋狞。...
    茶點(diǎn)故事閱讀 38,814評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡焚辅,死狀恐怖映屋,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情同蜻,我是刑警寧澤秧荆,帶...
    沈念sama閱讀 34,509評論 4 334
  • 正文 年R本政府宣布,位于F島的核電站埃仪,受9級特大地震影響乙濒,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜卵蛉,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,156評論 3 317
  • 文/蒙蒙 一颁股、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧傻丝,春花似錦甘有、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,882評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至泛释,卻和暖如春滤愕,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背怜校。 一陣腳步聲響...
    開封第一講書人閱讀 32,123評論 1 267
  • 我被黑心中介騙來泰國打工间影, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人茄茁。 一個月前我還...
    沈念sama閱讀 46,641評論 2 362
  • 正文 我出身青樓魂贬,卻偏偏與公主長得像,于是被迫代替她去往敵國和親裙顽。 傳聞我的和親對象是個殘疾皇子付燥,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,728評論 2 351

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn)愈犹,斷路器键科,智...
    卡卡羅2017閱讀 134,638評論 18 139
  • 1、對象拷貝有兩種方式:淺復(fù)制和深復(fù)制甘萧。顧名思義萝嘁,淺復(fù)制梆掸,并不拷貝對象本身扬卷,僅僅是拷貝指向?qū)ο蟮闹羔槪簧顝?fù)制是直接...
    滴答大閱讀 761評論 0 2
  • 307酸钦、setValue:forKey和setObject:forKey的區(qū)別是什么怪得? 答:1, setObjec...
    AlanGe閱讀 1,534評論 0 1
  • iOS 集合的深復(fù)制與淺復(fù)制 概念 對象拷貝有兩種方式:淺復(fù)制和深復(fù)制。顧名思義,淺復(fù)制徒恋,并不拷貝對象本身蚕断,僅僅是...
    難卻卻閱讀 319評論 0 1
  • 1. 屬性中copy與strong特性的區(qū)別 在開始學(xué)習(xí)淺復(fù)制(Shallow Copy)聊训、深復(fù)制(Deep Co...
    pro648閱讀 1,711評論 2 16