开发者

Override method syntax ios

I'm trying to override a method in my cellForRowAtIndexPath method like this

cell.customSwitch {
    - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
    {
        [super touchesEnded:touches withEvent:event];
        NSLog(@"customSwitch touchesended");
    }

};

however thi开发者_开发百科s isn't working (I'm normally a Java guy :P). Any help would be much appreciated!


There are a lot of similarities between Objective-C and Java, but that's not one of 'em. ;-)

If you want to create a cell with a customized -touchesEnded:withEvent: method, you'll need to declare and define that class separately. Something like:

@interface MyCell : UITableViewCell
{
//...
}
@end

@implementation MyCell
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
    [super touchesEnded:touches withEvent:event];
    NSLog(@"customSwitch touchesended");
}
@end

Once you've done that, you can use MyCell in your -cellForRowAtIndexPath:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜