1,程序的健壮性
2,编译时候校验执行时候校验
respondsToSelector,判断某个类 是否实现了该方法
- (IBAction)linkClickAction:(id)sender
{
[NSObject cancelPreviousPerformRequestsWithTarget:sender];
URLLinkView* view = (URLLinkView*)sender;
if ([self.mDelegate respondsToSelector:@selector(chatView:clickedURL:)]) {
[self.mDelegate chatView:self clickedURL:view.urlString];
}
}
如下等效:第一个有个延迟的效果
1,[_slimeView performSelector:@selector(endRefresh)
withObject:nil afterDelay:2
inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
2,[_slimeView endRefresh];
performSelector 与 self直接调用,,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/guligei/p/3794381.html