码迷,mamicode.com
首页 > 其他好文 > 详细

自定义Operation

时间:2015-08-27 15:08:30      阅读:108      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!