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!");
                }
           }*/
    );
  • 相关阅读:
    求树的某一层的节点最多
    快排 PAT 1101
    PAT 1098
    PAt 1099
    多项式求和
    pat 1100
    getline 函数
    数字的标准写法
    线性回归
    HTTP 中状态码 302的使用场景
  • 原文地址:https://www.cnblogs.com/hushuai-ios/p/3676619.html
Copyright © 2011-2022 走看看