使用componentsSeparatedByString的字符串中的数组名称

时间:2013-10-24 18:59:02

标签: objective-c variables nsstring

我在app appate中创建了一个数组。我希望数组名称的一部分是可变的。我试过componentsSeparatedByString:

我的最终代码有效:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
testAnimation.animationImages = appDelegate.A_SL1_Deal;

我希望“A_SL1”可变。我试过这个:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *app_del = @"appDelegate.";
testAnimation.animationImages = [app_del componentsSeparatedByString: @"A_SL1_Deal"];

我还尝试将所有内容转换为字符串:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
testAnimation.animationImages = [NSString stringWithFormat:@"appDelegate.%@_Deal", display_string];

0 个答案:

没有答案