0

我在我的应用程序委托中创建了一个数组。我希望数组名称的一部分是可变的。我试过了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];
4

0 回答 0