http://blog.csdn.net/numbbuaa/article/details/8556888
昨天刚发布了ios6.1版本,查看了一些苹果的官方api文档,看到一个instancetype关键字,几个UICollectionViewLayout的类方法,返回类型由id修改为instancetype,这两者有什么区别呢,上网搜了一下,
意思大概是,依照cocoa的命名规则,alloc,init这类方法,如果以id为返回类型,会返回类本身的类型,但类方法的返回类型,LLVM(clang)编译器无法判断,也就是说如果用id作为返回类型,有可能会将一个编译时错误变为一个运行时错误,instancetype则能够保证编译器正确判断返回的类型。
相关推荐
两个运算符虽然比较相似,其实区别还是非常大的,虽然不难区别,但是对于初学者可能稍有困扰,下面就简单介绍一下它们两者的区别,希望对需要的朋友有所帮助
- ( instancetype )interpolateToValue:( id )toValue progress:( double )progress behavior:(LNInterpolationBehavior)behavior; Swift public func interpolate(to toValue: Any, progress: Double) -> Self ...
@protocol ZSegmentedControlDelegate ...@property (nonatomic, weak)id <ZSegmentedControlDelegate> delegate; //@property (nonatomic, copy) void (^indexChangeBlock)(NSUInteger index);
@end@implementation MyObject+ ( instancetype ) appearance{ return ( id )[DMAppearanceRecorder appearanceRecorderForClass: self ];}@end然后,当您的对象准备好接受外观样式时,您可以调用: [...
ZYGCDTimer ZYGCDTimer主要用于替代NSTimer ,不会强持有目标,基于进行修改的,本质上是...+ ( instancetype )timerWithTimeInterval:( NSTimeInterval )interval target:( id )aTarget selector:( SEL )aSelector
- (instancetype)initWithTitle:(NSString *)title delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:...
CKComponentFadeTransition ...+ ( instancetype )newWithURL:( NSURL *)url imageDownloader:( id )imageDownloader scenePath:( id )scenePath size:( const CKComponentSize &)size options:( const
@property (weak, nonatomic) id delegate; @property (strong, nonatomic) UIColor *textColor; @property (strong, nonatomic) UIColor *separatarColor; - (instancetype)initWithItems:(NSArray *)items ...
粒子云框架 粒子云框架是一种云资源供应框架,可以完全自定义和扩展,可以通过代码调用,并且不需要手动维护资源状态。 粒子云框架可实现对分层云基础架构进行建模,自动化部署以及管理... "InstanceType": "t2.micro",
概述NSManagedObjectImportOperation 这是通过创建的NSOperation子类+ (instanceType)operationWithData:( id )data managedObjectClass:( Class )class guaranteedInsert:( BOOL )guaranteedInsert saveOnBatchSize...
(instancetype)intance; /** 数据库中是否存在表 */ - (BOOL)isExistWithTableName:(NSString*)name; /** 默认建立主键id 创建表(如果存在则不创建) , keys 数据存放要求@[字段名称1,字段名称2] */ ...
应使用指定的初始化程序创建 ABCounterViewController 的实例: -(instancetype) initWithDelegate:(id<ABCounterViewController)delegate startCount:(float)startCount minCount:(float)minCount maxCount:...
– (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /**/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles,...
介绍WSChartView WSLineChartView WSBarChartView WSData WSBar WSLabel用法在里面- (instancetype)initWithFrame:(CGRect)frame WithChartViewStyle:(WSChartViewStyle)Style WithDataSource:(id)source;...
简述 在仿写豆瓣的时候,发现了根据评分不同,星级数也不同的星级条。 百度一搜,发现Android有自带控件UIRatingBar,而iOS得要自己写…好吧,那就写吧。 图片素材 ...- (instancetype)initWithFram