我是Objective C中的新手,试图弄清楚^操作符是什么?在浏览一些源代码的同时,我看到下一个建设:
dispatch_once(&oncetoken,^{ UIGraphicsBeginImageContextWithOptions(CGSizeMake(20.f,13.f),NO,0.0f); [[UIColor blackColor] setFill]; [[UIBezierPath bezierPathWithRect:CGRectMake(0,20,1)] fill]; [[UIBezierPath bezierPathWithRect:CGRectMake(0,5,10,1)] fill]; [[UIColor whiteColor] setFill]; [[UIBezierPath bezierPathWithRect:CGRectMake(0,1,2)] fill]; [[UIBezierPath bezierPathWithRect:CGRectMake(0,6,11,2)] fill]; defaultimage = UIGraphicsGetimageFromCurrentimageContext(); UIGraphicsEndImageContext(); });
我想知道什么是^?
解决方法
^表示Objective-C中块定义的开始.
看看这里:http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html#//apple_ref/doc/uid/TP40007502-CH7-SW1
请注意,在这种情况下,^不是运算符,它是Objective-C的语法的一部分@ Mike的投票答案严格是“^操作符”的正确定义