私有变量访问/延后执行代码块

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!");
            }
       }*/
);

 

posted @ 2014-04-20 16:13  MittyoO  阅读(145)  评论(0编辑  收藏  举报