how to block a superclass method to be called to a subclass

后端 未结 5 1735
情歌与酒
情歌与酒 2021-01-19 03:37

I\'m extending the functionality of a class with a subclass, and I\'m doing some dirty stuff that make superclass methods dangerous (app will hang in a loop) in the context

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 03:37

    note: I'm ObjC/Cocoa newcomer:

    @implementation MyClass
    -(void)myMethod:(NSString *)txt{
        if([self class] != [MyClass class]) return;
        NSLog(@"Hello");
    }
    @end
    

    Peter

提交回复
热议问题