• 英语----名词性从句的混合练习(下)


    #import <Foundation/Foundation.h>

     @interface Person : NSObject

     +(instancetype)sharePerson;

     @end

     #import "Person.h"

     @implementation Person

     static Person *_instance = nil;

     +(void)load{

        _instance = [[self alloc] init];// 已进入就调用

    }

     +(instancetype)sharePerson{

        return _instance;

    }

     +(instancetype)alloc{

        if (_instance) { // 禁止调用alloc

         NSException *exception =    [NSException  exceptionWithName:NSInternalInconsistencyException reason:@"There can only be on Person instance" userInfo:@{}];

            [exception raise];// 抛出异常

        }

        return [super alloc];

    }

     @end

    /*单例子*/ 

    + (instancetype)shareInstance{

         static Person *sharedInstance = nil;

        static dispatch_once_t prdictate;

        dispatch_once(&prdictate, ^{

                  sharedInstance = [[Person alloc] init];

        });

        return sharedInstance;

    }

  • 相关阅读:
    OutputCache详解
    C#数值类型的转换
    C#变量类型转换
    C#和.net
    数组
    mvc
    C#部分基础知识
    项目开发-->高级功能汇总
    项目开发-->基础功能汇总
    C#基础篇
  • 原文地址:https://www.cnblogs.com/1018475062qq/p/7071878.html
Copyright © 2020-2023  润新知