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