嗨:)我正在尝试创建一个NSStrings的静态C数组.
这是我试过的:
static NSString** polygonNames = {@"Radical Isotope",@"Point",@"Line",@"Triangle",@"Square",@"Pentagon",@"Hextagon",@"Heptagon",@"Octagon",@"Nonagon",@"Decagon",@"Hendecagon",@"Dodecagon",@"Tridecagon",@"Tetradecagon",@"Pentadecagon",@"Hexadecagon",@"Heptadecagon",@"Octadecagon",@"Enneadecagon"};
没有编译器错误,但是我收到41个警告,所有这些都是以下三个之一:
"warning: initialization from incompatible pointer type" "warning: excess elements in scalar initializer" "warning: (near initialization for 'polygonNames')"
这让我相信当我使用这个类,我将被提供大量的sigbarts或一些其他内存访问错误…
初始化NSStrings的静态数组的最佳方法是什么(最好是内联,我想使用C数组,而不是NSArrays)?
解决方法
尝试这个:
static NSString *polygonNames[] = { @"Radical Isotope",/* etc */ };