有10個recogniser要分配給類屬性,如何增加()loop屬性名的數值部分?
for (int i=0; i < [_myArray count]; i++)
{
myClassInstance.recognizer = pangesture + i ?? // 無效,不知道怎麼用
}
這樣就行了:
for(int i = 0; i < [_myArray count]; i++)
{
NSString *nameOfProperty = [NSString stringWithFormat:@"pangesture%d", i];
UIPanGestureRecognizer *recogniser = [self valueForKey:nameOfProperty];
}
用到key-value;輸出口需要遵循KVC,不然就不能下載NIB.