У меня есть UIImageView под названием platform1
, platform2
, platform3
и т. Д. У меня есть int
, называемый platformNumber
, исходящий из одного метода (method1) в другой метод (метод2).Как изменить имя переменной в зависимости от другой переменной?
method2 (содержание не полезные на мой вопрос):
CGPoint origin = platform1.center;
CGPoint target = CGPointMake(platform1.center.x, platform1.center.y+10);
CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"position.y"];
bounce.duration = 0.1;
bounce.fromValue = [NSNumber numberWithInt:origin.y];
bounce.toValue = [NSNumber numberWithInt:target.y];
bounce.repeatCount = 1;
bounce.autoreverses = YES;
[platform1.layer addAnimation:bounce forKey:@"position"];
Как изменить его так, везде, где platform1
.center.x появляется, оно меняется в зависимости platform[platformNumber]
в platformNumber
значение, переданное через?
Спасибо, любая помощь будет очень признательна!
с использованием 'valueForKey', если они являются свойством объекта или выполняют переключатель в начале:' UIView * aPlateform; switch (thePlaftormNumber) {case 1: aPlateform = plaform1; break; и т. д.} ' – Larme