Weird objective-c syntax - square brackets and @ sign

后端 未结 2 1963
渐次进展
渐次进展 2020-12-11 06:23

I\'m using GHSidebarNav in one of my projects and I came across this code allocating an array of objects. I just have no idea what its doing. Is it just an array? What is th

相关标签:
2条回答
  • 2020-12-11 06:37

    That's a new objective C literal that is declaring a multi dimensional array.

    It's replacing [NSArray arrayWithObjects:[NSArray arrayWithObjects:...], [NSArray arrayWithObjects:..]]];

    0 讨论(0)
  • 2020-12-11 07:04

    These are array literals, a type of container literal, available in Xcode 4.4 and later.

    See:

    • "Literal syntax" section of the discussion of arrays in the Programming with Objective C
    • Objective-C Literals discussion at the LLVM site
    • WWDC 2012 Modern Objective-C, about 19-20 minutes into it
    • WWDC 2012 Migrating to Modern Objective-C
    0 讨论(0)
提交回复
热议问题