<分区>
标签 ios objective-c cocoa
<分区>
本质上,我想要做的是将我创建的字符串作为变量的名称。然而,对于下面的代码,我可以理解地得到一个重定义错误。
NSString *pointerName = @"myPointer";
NSArray *pointerName = [NSArray array];
有没有办法使用字符串作为其内容,而不是让编译器认为我的意思是我要创建的新对象的名称?
最佳答案
而不是存储指针的字符串值。你可以像这样使用
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
for (int i = 0; i < [array1 count]; i++)
{
[dict setObject:[NSArray array] forKey:[array1 objectAtIndex:i]];
}
希望对你有用..
关于ios - 我可以使用字符串变量中的名称创建指向对象的指针吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19588096/
相关文章:
Objective-C : Need advice on setting instance variables in init method
ios - 在 .m 文件的@interface 中初始化的 CGPoint 变量不能有值
objective-c - [[NSMutableData alloc] initWithLength :] and CFDataCreateMutable()? 之间的区别
ios - dispatch_async -[__NSArrayM objectAtIndex :]: index 0 beyond bounds for empty array
objective-c - 如何在 NSDictionary 中保存(和检索) NSAttributedString