private delegate int MyMethod();private int method(){ Thread.Sleep(10000); return 100;}private void MethodCompleted(IAsyncResult asyncResult){ ...
分类:
编程语言 时间:
2014-12-04 12:05:53
阅读次数:
155
简单谈一下对委托的认识,算是对这篇博客( 这里)的理解和概括吧!
委托(Delegate)首先可以看做一个特殊的类,而一些函数是他的变量取值范围。
如声明一个委托:public delegate void GreetingDelegate(string name);那么我们在别的函数中把函数名当做变量传进来,这样子就可以调用相应的函数了。委托应该先声明才能用,注意作用范围。在任意函数里...
//上传图片
-(void)showActionSheet
{
//在这里呼出下方菜单按钮项
myActionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButto...
分类:
Web程序 时间:
2014-12-03 19:26:08
阅读次数:
129
tableViews?=?[[UITableView?alloc]?initWithFrame:CGRectMake(0,?0,?SCREEN_WIDTH,?SCREEN_HEIGHT)];
????tableViews.delegate?=?self;
????tableViews.dataSource?=?self;
????tableVi...
分类:
其他好文 时间:
2014-12-03 12:41:23
阅读次数:
144
转自http://www.cnblogs.com/LittleFeiHu/p/4035166.htmlAction:封装一个方法,该方法不具有参数并且不返回值public delegate void Action()Action:Action的泛型实现了1到16个传入参数的定义,但是仍然没有返回值,...
From:view6-view7(00:17)1.Introduction: Implement two gestures:pinch and pan. We first implement the pinch. Weadd delegate to faceView(the view) that a...
在Objective-C中经常会用到单例模式。最常见的就是:[UIApplication sharedApplication].delegate这里的sharedApplication就是一个返回单例的方法。所谓的单例模式也就是在整个APP、或者软件中只有这个类的这么一个对象。可以保存一些全局的设置...
分类:
编程语言 时间:
2014-12-02 18:43:46
阅读次数:
138
1.效率肯定是delegate比nsnotification高。2. delegate方法比notification更加直接,最典型的特征是,delegate方法往往需要关注返回值, 也就是delegate方法的结果。比如-windowShouldClose:,需要关心返回的是yes还是no。所以d...
分类:
编程语言 时间:
2014-12-01 19:06:17
阅读次数:
125
Objective-c 代理模式(delegate)一、什么事代理模式?代理模式是在oc中经常遇到的一种设计模式,那什么叫做代理模式呢? 举个例子:有一个婴儿,他本身不会自己吃饭和洗澡等等一些事情,于是婴儿就请了一个保姆,于是婴儿和保姆之间商定了一个协议,协议中写明了保姆需要做什么事情, 而保姆就是...
分类:
其他好文 时间:
2014-11-30 13:44:25
阅读次数:
108
1 public class program( 2 public delegate int myDelegate(int i,int j); 3 public static void main(string[] args){ 4 5 //普通调...
分类:
其他好文 时间:
2014-11-29 14:36:01
阅读次数:
112