美文网首页
如何禁用iOS系统方法?

如何禁用iOS系统方法?

作者: 青波志 | 来源:发表于2016-02-24 17:01 被阅读270次

出于某种需求,我需要禁用iOS系统提供的某些系统方法。可以采用如下的方法:

+(instancetype) alloc __attribute__((unavailable("call other method instead")));
-(instancetype) init __attribute__((unavailable("call other method instead")));
+(instancetype) new __attribute__((unavailable("call other method instead")));

一旦我们在程序中使用到了alloc、init、new等相关方法的时候,就会出现如下错误提示:

![][1]

原文链接
[1]: http://7xrmkz.com1.z0.glb.clouddn.com/How-to-disable-system-methods.png

相关文章

网友评论

      本文标题:如何禁用iOS系统方法?

      本文链接:https://www.haomeiwen.com/subject/kndikttx.html