美文网首页
__block变量的说明(完结)

__block变量的说明(完结)

作者: json_jie | 来源:发表于2015-03-27 10:51 被阅读202次

    // gloabString = @"gloabString";
    // NSLog(@"init == %@",gloabString);
    // typedef void(^myBlock) (int a);
    // myBlock block = ^(int m){
    // NSLog(@"%d",m);
    // gloabString = @"changeGloabString";
    // NSLog(@" in %@",gloabString);
    // };
    // NSLog(@"pro == %@",gloabString);
    // block(10);
    // NSLog(@" out %@",gloabString);
    /**
    init == gloabString
    pro == gloabString
    10
    in changeGloabString
    out changeGloabString
    */
    全局变量、静态变量 ?要看看内存的事情哦,你就会理解了

    // NSString partString = @"partString";
    // NSLog(@"init partString %@",partString);
    // typedef void(^myBlock) (int a);
    // myBlock block = ^(int m){
    // NSLog(@"partString %@",partString);
    // };
    // partString = @"changePartString";
    // NSLog(@"partString 1 %@",partString);
    // block(10);
    // NSLog(@"partString 2 %@",partString);
    // /
    *
    // init partString partString
    // partString 1 changePartString
    // partString partString
    // partString 2 changePartString
    // */

    __block NSString blockString = @"blockString";
    NSLog(@"init Value %@",blockString);
    typedef void(^myBlock) (int a);
    myBlock block = ^(int m){
    blockString = @"changeBlockString";
    NSLog(@"blockString in %@",blockString);
    };
    NSLog(@"blockString out1 %@",blockString);
    block(111);
    NSLog(@"blockString out2 %@",blockString);
    /
    *
    init Value blockString
    blockString out1 blockString
    blockString in changeBlockString
    blockString out2 changeBlockString
    */

    相关文章

      网友评论

          本文标题:__block变量的说明(完结)

          本文链接:https://www.haomeiwen.com/subject/ghknxttx.html