采用现代Objective-C
- @interface MyObject : NSObject
- + (instancetype)factoryMethodA;
- + (id)factoryMethodB;
- @end
- @implementation MyObject
- + (instancetype)factoryMethodA
- {
- return [[[self class] alloc] init];
- }
- + (id)factoryMethodB
- {
- return [[[self class] alloc] init];
- }
- @end
- void doSomething()
- {
- NSUinteger x, y;
- // Return type of +factoryMethodA is taken to be "MyObject *"
- x = [[MyObject factoryMethodA] count];
- // Return type fo +factoryMethodB is "id"
- y = [[MyObject factoryMethodB] count];
- }
- main.m: 'MyObject' may not respond to 'count'
- @interface MyObjectSubclass : MyObject
- @end
- void doSomethingElse()
- {
- NSString *aString = [MyObjectSubclass factoryMethodA];
- }
- main.m: Incompatible pointer types initializing 'NSString *'
- with an expression of type 'MyObjectSubclass *'
- @interface MyObject
- - (id)myFactoryMethod;
- @end
- @interface MyObject
- - (instancetype)myFactoryMethod;
- @end
- @property (readonly, getter=isBlue) BOOL blue;
- @property (readonly, getter=isBlue) BOOL blue;
- if(color.blue){}
- if(color.isBlue){}
- if([color isBlue]){}
- - (NSColor *)backgroundColor;
- - (void)setBackgroundColor:(NSColor *)color;
- @property (copy) NSColor *backgroundColor;
- typedef NS_ENUM(NSInteger, UITableViewCellStyle){
- UITableViewCellStyleDefault,
- UITableViewCellStyleValue1,
- UITableViewCellStyleValue2,
- UITableViewCellStyleSubtitle
- }
- typedef NS_OPTIONS(NSUInteger, UIViewAutoresizeing){
- UIViewAutoresizeingNone = 0,
- UIViewAutoresizeingFlexibleLeftMargin = 1 << 0,
- UIViewAutoresizeingFlexibleWidth = 1 << 1,
- UIViewAutoresizeingFlexibleRightMargin = 1 << 2,
- UIViewAutoresizeingFlexibleTopMargin = 1 << 3,
- UIViewAutoresizeingFlexibleHeight = 1 << 4,
- UIViewAutoresizeingFlexibleBottomMargin = 1 << 5
- }
- enum{
- UITableViewCellStyleDefault,
- UITableViewCellStyleValue1,
- UITableViewCellStyleValue2,
- UITableViewCellStyleSubtitle
- };
- typedef NSInteger UITableViewCellStyle;
- typedef NS_ENUM(NSInteger, UITableViewCellStyle){
- UITableViewCellStyleDefault,
- UITableViewCellStyleValue1,
- UITableViewCellStyleValue2,
- UITableViewCellStyleSubtitle
- }
- enum {
- UIViewAutoresizeingNone = 0,
- UIViewAutoresizeingFlexibleLeftMargin = 1 << 0,
- UIViewAutoresizeingFlexibleWidth = 1 << 1,
- UIViewAutoresizeingFlexibleRightMargin = 1 << 2,
- UIViewAutoresizeingFlexibleTopMargin = 1 << 3,
- UIViewAutoresizeingFlexibleHeight = 1 << 4,
- UIViewAutoresizeingFlexibleBottomMargin = 1 << 5
- };
- typedef NSUInteger UIViewAutoresizing;
- typedef NS_OPTIONS(NSUInteger, UIViewAutoresizeing){
- UIViewAutoresizeingNone = 0,
- UIViewAutoresizeingFlexibleLeftMargin = 1 << 0,
- UIViewAutoresizeingFlexibleWidth = 1 << 1,
- UIViewAutoresizeingFlexibleRightMargin = 1 << 2,
- UIViewAutoresizeingFlexibleTopMargin = 1 << 3,
- UIViewAutoresizeingFlexibleHeight = 1 << 4,
- UIViewAutoresizeingFlexibleBottomMargin = 1 << 5
- }
采用现代Objective-C的更多相关文章
- 【转】从Go、Swift语言出发
Google于2009年第一次提出了Go的构思,Facebook在去年春天引入了Hack,随后不久Apple也发布了其Swift语言. 在战争中,胜利者写历史书:在科技中,赢的公司都在写编程语言.互联 ...
- 从Go、Swift出发:语言的选择需谨慎
本文转自 : http://www.csdn.net/article/2014-12-09/2823025 摘要:无论是开源的Go,还是闭源的Swift,新的语言总是利弊一体.不过可以确定的是,新的语 ...
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- 浅谈Objective—C中的面向对象特性
Objective-C世界中的面向对象程序设计 面向对象称程序设计可能是现在最常用的程序设计模式.如何开发实际的程序是存在两个派系的-- 面向对象语言--在过去的几十年中,很多的面向对象语言被发明出来 ...
- iOS开发——技术精华Swift篇&Swift 2.0和Objective-C2.0混编之第三方框架的使用
swift 语言是苹果公司在2014年的WWDC大会上发布的全新的编程语言.Swift语言继承了C语言以及Objective-C的特性,且克服了C语言的兼容性问题.Swift语言采用安全编程模式,且引 ...
- 第一章 熟悉Objective -C 编写高质量iOS与OS X代码的52 个有效方法
第一章 熟悉Objective -C 编写高质量iOS与OS X代码的52 个有效方法 第一条: 了解Objective-C 语言的起源 关键区别在于 :使用消息结构的语言,其运行时所应执行 ...
- 论文翻译:2020_FLGCNN: A novel fully convolutional neural network for end-to-end monaural speech enhancement with utterance-based objective functions
论文地址:FLGCNN:一种新颖的全卷积神经网络,用于基于话语的目标函数的端到端单耳语音增强 论文代码:https://github.com/LXP-Never/FLGCCRN(非官方复现) 引用格式 ...
- 采用MiniProfiler监控EF与.NET MVC项目(Entity Framework 延伸系列1)
前言 Entity Framework 延伸系列目录 今天来说说EF与MVC项目的性能检测和监控 首先,先介绍一下今天我们使用的工具吧. MiniProfiler~ 这个东西的介绍如下: MVC Mi ...
- 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)
前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...
随机推荐
- jdbc知识问答 分类: 面试 2015-07-10 22:05 5人阅读 评论(0) 收藏
1 JDBC连接数据库6步 Load the JDBC Driver Establish the Database Connection Create a Statement Object Execu ...
- NDK(16)Jni中GetStaticFieldID和GetMethodID 中的类型标识串
env在GetStaticFieldID和GetMethodID 时,函数参数和返回值的类型要指定类型标识串,如: jmethodID init = env->GetMethodID(clz,& ...
- Mybatis中配置Mapper的方法
在这篇文章中我主要想讲一下Mybatis配置文件中mappers元素的配置.关于基础部分的内容可以参考http://haohaoxuexi.iteye.com/blog/1333271. 我们知道在M ...
- Oracle 数据集成的实际解决方案
就针对市场与企业的发展的需求,Oracle公司提供了一个相对统一的关于企业级的实时数据解决方案,即Oracle数据集成的解决方案.以下的文章主要是对其解决方案的具体描述,望你会有所收获. Oracle ...
- bzoj2351 2462
我没写hash,写了一些奇怪的做法,好像被hash随便操了…… 如果没有多测,那么这道题是白书上的例题 把询问矩阵当作a个模板串,建成一个ac自动机 把一开始的矩阵当作n个串放到自动机上匹配,找到a个 ...
- bzoj2797
对和排序,显然最小是a1+a2,次小a1+a3 然后穷举哪里是a2+a3 这样a1,a2,a3就求出来了 注意a2+a3只可能是前n+1项中的一个,所以穷举这步是O(n)的 接下来我们把已经确定的数的 ...
- Vagrant工具
Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我们可以通过 Va ...
- Android基础_3 Activity相对布局
相对布局要比前面讲的线性布局和表格布局要灵活一些,所以平常用得也是比较多的.相对布局控件的位置是与其周围控件的位置相关的,从名字可以看出来,这些位置都是相对的,确定出了其中一个控件的位置就可以确定另一 ...
- C#开发COM+组件和ActiveX控件
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices ...
- Java [Leetcode 326]Power of Three
题目描述: Given an integer, write a function to determine if it is a power of three. Follow up:Could you ...