单例

单例模式:
是一种特殊的工厂方法,特殊在于只能生成唯一的对象,使用static来延长其作用域

命名格式: +(id)shared + 类名

+(id)shareStudent{
      static TRStudent *s = nil;
if( s == nil ){
      s = [[TRStudent alloc ] init ];
}
return s;
}

工厂方法也是需要声明的,不声明的方法是私有方法或者是重写的方法

成功的三大原则: 1、坚持 2、不要脸 3、坚持不要脸
原文地址:https://www.cnblogs.com/xulinmei/p/7413504.html