作为oc开发guys,这个很熟悉,不然你就去run
一、OC中的对象方法
1.以减号“-”开头
2.只能让对象调用,没有对象,这个方法根本不可能被执行
3.对象方法能访问实例变量(也就是成员变量)
二、OC中的类方法
1.以加号“+”开头
2.只能用类名调用,对象不能调用
3.类方法中不能访问实例变量(也就是成员变量)
4.适用场合:当不需要访问成员变量的时候,尽量用类方法
对比Swift中类方法
1、class func customizedNavigationController() -> UINavigationController{}
2、

对象方法Swift中实例方法
2、func customizedNavigationController() -> UINavigationController{
代码
}
func对象方法有分为
(1)无参数无返回值函数

(2)多个参数无返回值

(3)多个参数有返回值

(4)具有多个参数多个返回值

(5)可选的元组返回类型

(6)指定参数标签

(7)省略参数标签

(8)默认参数值

(9)不固定参数值

(10)进出参数

(11)函数类型作为参数返回类型

(12)函数的嵌套:函数体内可以再定义函数

类方法前面加小写的class
网友评论