I am an iOS developer (very little experience) that develops in Swift. My next project is to make a two player tic tac toe game using Open Gl ES. Swift is not the best language choice for OpenGl ES development so I am starting to learn Objective C. I am following a book that expalins Open GL ES for iOS specifically, in Objective C. While reading the book they have the following data strucuture that stores vertices and they say it is an array. Here is the code...
我是一个在Swift中开发的iOS开发人员(非常少的经验)。我的下一个项目是使用Open Gl ES制作一个双人tic tac toe游戏。 Swift不是OpenGl ES开发的最佳语言选择,因此我开始学习Objective C.我正在阅读一本专门针对iOS的Open GL ES的书,目标C.在阅读本书时,他们有以下数据结构存储顶点,他们说这是一个数组。这是代码......
static const SceneVertex vertices[] = {{{-0.5f, -0.5f, 0.0}},{{ 0.5f, -0.5f, 0.0}},{{-0.5f, 0.5f, 0.0}}};
This does not look like an array in Objective-C. Is this in C? Also why are the initialization of the array is a little weird. Why are their curly braces instead of square brackets to initialize the array?
这看起来不像Objective-C中的数组。这是在C?另外为什么数组的初始化有点奇怪。为什么用花括号而不是方括号来初始化数组?
1 个解决方案
#1
6
The format for initializing an array in C is to encase the values used to initialize the array in {}
在C中初始化数组的格式是在{}中包含用于初始化数组的值
double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
#1
6
The format for initializing an array in C is to encase the values used to initialize the array in {}
在C中初始化数组的格式是在{}中包含用于初始化数组的值
double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};