在一个类的方法方法我声明如下:我可以使用类方法,如委托回调
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Hello"
message:@"World"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Done", nil];
现在即使含有方法是一个类方法,编译器不抱怨的delegate:self
。现在成为代表我必须在UIAlertViewDelegate
协议中实现该方法。
现在问题,如果该方法是一个类方法或不,以便在用户与我的AlertView交互时调用?
我在问这个问题,因为我的类没有任何实例变量,所以我宁愿它只包含类方法。
你的意思是类方法? :P – 2012-01-16 17:08:19
您可以尝试使用班级名称,而不是指导实例的self。 – 2012-01-16 17:11:41
另请参阅http://stackoverflow.com/questions/1781046/dynamically-invoke-a-class-method-in-objective-c的答案。我认为这是相关的。在类方法中使用 – 2012-01-16 17:14:41