首页 > 其他 > 详细

自定义Operation

时间:2015-08-27 15:06:43      阅读:381      评论:0      收藏:0      [点我收藏+]

1.要自定义一个Operation 首先要创建一个继承于NSOperation的类。

2.在创建好的类的.h文件声明自定义的方法:-(instancetype)initWithDownLoadMessage:(NSString *)url;

3.在创建好的类的.m文件实现自定义方法:

-(instancetype)initWithDownLoadMessage:(NSString *)url{

    self =[super init];

    if (self) {

        URLString =url;

    }

    return self;

}

4.然后我们只需要在需要用到的类里面导入之前创建号的类:#import “DownLoadOperation.h"

5.初始化类的对象,应用类方法:

 imageview  =[[UIImageView alloc]initWithFrame:self.view.frame];

    [self.view addSubview:imageview];

    DownLoadOperation *download =[[ DownLoadOperation alloc]initWithDownLoadMessage:@"http://file.bmob.cn/M01/37/F1/oYYBAFXdo8yAFY8QAABIFt81XEM849.png"];

 

自定义Operation

原文:http://www.cnblogs.com/popper123/p/4763211.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!