Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在objective C中定义字符串的二维常量数组_Objective C_Arrays_Nsstring - Fatal编程技术网

Objective c 如何在objective C中定义字符串的二维常量数组

Objective c 如何在objective C中定义字符串的二维常量数组,objective-c,arrays,nsstring,Objective C,Arrays,Nsstring,我已经声明了以下有效常数: NSString * const LETTER_SELECTED[] = {@"A",@"B",@"C",@"D",@"E",@"F"}; 现在我想声明一个类似的常数,但是维度2不起作用: NSString * const LETTER_SELECTED[][] = { {@"A",@"uc"}, {@"b",@"lc"},

我已经声明了以下有效常数:

NSString * const LETTER_SELECTED[] = {@"A",@"B",@"C",@"D",@"E",@"F"};
现在我想声明一个类似的常数,但是维度2不起作用:

NSString * const LETTER_SELECTED[][] = {
                        {@"A",@"uc"},
                        {@"b",@"lc"},
                        {@"c",@"lc"},
                        {@"d",@"lc"},
                        {@"E",@"uc"},
                        {@"f",@"lc"}};
我是一名C程序员,知道如何在Objective-C中声明这一点吗

提前感谢

这是objective-c中NSArray的外观

@interface MyClass ()
@property (nonatomic, strong) NSArray *my2DArrayOfStrings;
@end

@implementation MyClass
- (instancetype)init {
    self = [super init];
    self.my2DArrayOfStrings = @[
                                @[ @"A", @"uc" ],
                                @[ @"b", @"lc" ],
                                @[ @"c", @"lc" ],
                                @[ @"d", @"lc" ],
                                ];
    return self;
}
@end
然而,在您的示例中,您真正想要的似乎是一本NSDictionary


非常感谢你,深红色
@interface MyClass ()
@property (nonatomic, strong) NSDictionary *stringDictionary;
@end

@implementation MyClass
- (instancetype)init {
    self = [super init];
    self.stringDictionary = @{
                              @"A" : @"uc",
                              @"b" : @"lc",
                              @"c" : @"lc",
                              @"d" : @"lc",
                              };
    return self;
}
@end