[英]How to change method dispatch table in objective-c?
作為一個實際示例,在UIView中,設置setNeedsDisplay時將調用drawRect。 我希望第一次調用不同的drawRect例程,而不是隨后的更新。 因此,例如,我希望drawRect首次調用drawRectFirstTime,而drawRect則為后續的setNeedsDisplay調用drawRectSubsequentUpdate。
在Objective-C中應該如何完成?
從我的頭頂:
- (void)drawRect:(NSRect)rect
{
static BOOL first = YES;
if (first == NO)
{
[self drawRectSubsequentUpdate:rect];
} else {
[self drawRectFirstTime:rect];
first = NO
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.