zoukankan      html  css  js  c++  java
  • 私有变量访问/延后执行代码块

    1.私有变量访问

    NSString *str;  
     Mobj *obj = [[Mobj alloc] init];  
     object_getInstanceVariable(obj, "mt_", (void *)&str);  
     NSLog(@"%@",str);  
     [obj release]; 

    2.延后执行代码块

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            /*要执行的代码
                UIGraphicsBeginImageContext(view.bounds.size);
                [view.layer renderInContext:UIGraphicsGetCurrentContext()];
                
                UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
                
                UIGraphicsEndImageContext();
                
                NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingFormat:@"/%d.png",_index];
                if ([UIImagePNGRepresentation(image) writeToFile:path atomically:YES]) {
                    _index += 1;
                    NSLog(@"Succeeded!");
                }
                else {
                    NSLog(@"Failed!");
                }
           }*/
    );
  • 相关阅读:
    树的重心备忘
    Hdu 2196
    HDU 1520
    TOJ1068 商务旅行
    携程HDU第一场1001
    USACO 4.3.2 The Primes
    Html常用标签的应用
    Html
    开班心得
    for循环练习及字符串处理
  • 原文地址:https://www.cnblogs.com/hushuai-ios/p/3676619.html
Copyright © 2011-2022 走看看