单例传值

来源:互联网 发布:js九九乘法表代码 编辑:程序博客网 时间:2024/06/05 23:52



#import <Foundation/Foundation.h>


@interface DQYPassByValue : NSObject


/**

 *后台返回的日期

 */

@property (nonatomic,copy)NSString *netWorkBackDay;



/**

 *后台返回的下级电话号码

 */

@property (nonatomic,copy)NSString *netWorkBackTelephone;



+(instancetype)sharePassValue;



-------------

#import "DQYPassByValue.h"


@implementation DQYPassByValue


+(instancetype)sharePassValue{


    return [[selfalloc]init];

}


#pragma mark 分配内存创建对象

+(instancetype)allocWithZone:(struct_NSZone *)zone{


    static DQYPassByValue *passValue;

    

    static dispatch_once_t onceVale;

    dispatch_once(&onceVale, ^{

        

        if (passValue == nil) {

            

            passValue = [super allocWithZone:zone];

        }

    });

    

    return passValue;

}




//在.pch文件里引用,然后就可以全局使用了


self.ymdLabel.text =[NSStringstringWithFormat:@"%@",[DQYPassByValuesharePassValue].netWorkBackDay];





0 0
原创粉丝点击