问题描述
CAGradientLayer *毕业= [CAGradientLayer层]
grad.colors = $阵列(ColRGBA2(1,0,0,1),ColRGBA2(0,1,0,1),ColRGBA2(0,0,1,1),ColRGBA2(0,0,0,0) );
grad.startPoint = CGPointMake(0,0);
grad.endPoint = CGPointMake(1,0);
grad.colors = $阵列(ColRGBA2(1,0,0,1),ColRGBA2(0,1,0,1),ColRGBA2(0,0,1,1),ColRGBA2(0,0,0,0) );
这句话有一个美元符号是什么意思?关于它的任何联系?
这不是语言的一个特征,这些都是某些人使用集合便利intializers。例如:
$阵列(富,酒吧,巴兹)
扩展为:
[NSArray的arrayWithObjects:富,酒吧,巴兹,零]
我不知道这是否是值得的麻烦。我不有一个链接,提供这些宏,图书馆也许别人呢?
顺便说一句,看起来我们将有数组,字典放在X code 4.4的一些其他对象的官方文字。细节似乎NDA下的那一刻,但有在黑客新闻一些讨论。
CAGradientLayer *grad = [CAGradientLayer layer];
grad.colors = $array(ColRGBA2(1, 0, 0, 1), ColRGBA2(0, 1, 0, 1), ColRGBA2(0, 0, 1, 1), ColRGBA2(0, 0, 0, 0));
grad.startPoint = CGPointMake(0, 0);
grad.endPoint = CGPointMake(1, 0);
grad.colors = $array(ColRGBA2(1, 0, 0, 1), ColRGBA2(0, 1, 0, 1), ColRGBA2(0, 0, 1, 1), ColRGBA2(0, 0, 0, 0));
in this sentence have a dollar sign what does this mean?any links about it?
That’s not a feature of the language, these are convenience intializers for collections that some people use. For example:
$array(foo, bar, baz)
expands to:
[NSArray arrayWithObjects:foo, bar, baz, nil]
I’m not sure if it’s worth the trouble. And I don’t have a link to the library that provides these macros, maybe somebody else does?
By the way, it looks like we will have official literals for arrays, dictionaries and some other objects in Xcode 4.4. The details appear to be under NDA at the moment, but there’s some discussion at Hacker News.
这篇关于是什么美元符号在Objective-C是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!