Kann mir das jemand erklären und gibt es überhaupt eine Möglichkeit, eine zugewiesene Funktion aus einer anderen Klasse in einem UISwitch aufzurufen?< /p>
Funktioniert nicht:
Code: Select all
@implementation CustomClass : NSObject
-(void) test {
NSLog(@"TEST");
}
@end
UISwitch *uiSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 50, 50)];
[uiSwitch addTarget:[CustomClass alloc] action:@selector(test) forControlEvents:UIControlEventValueChanged];
[self addSubview:uiSwitch];
Code: Select all
@implementation CustomClass : NSObject
+(void) test {
NSLog(@"TEST");
}
@end
UISwitch *uiSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 50, 50)];
[uiSwitch addTarget:[CustomClass class] action:@selector(test) forControlEvents:UIControlEventValueChanged];
[self addSubview:uiSwitch];