コンテキスト: という名前の NSObject から派生したカスタム クラスにいくつかの CGPathRef がありmodel
ます。実行時に生成する文字列に基づいて、特定の CGPathRef を返す方法を探しています。
KVC を使用できる場合の簡略化された例:
#model.h
@property (nonatomic) CGMutablePathRef pathForwardTo1;
@property (nonatomic) CGMutablePathRef pathForwardTo2;
@property (nonatomic) CGMutablePathRef pathForwardTo3;
...
#someVC.m
-(void)animateFromOrigin:(int)origin toDestination:(int)destination{
int difference = abs(origin - destination);
for (int x =1; x<difference; x++) {
NSString *pathName = [NSString stringWithFormat:@"pathForwardTo%d", x];
id cgPathRefFromString = [self.model valueForKey:pathName];
CGPathAddPath(animationPath, NULL, cgPathRefFromString);
}
}
質問: KVC に準拠していないプロパティ (CGPathRef) に、文字列として表された名前だけでアクセスするにはどうすればよいですか?