object-c中delegate使用简单方法

本文介绍了在Objective-C中使用Delegate的基本步骤,包括声明定义、设置委托对象,并通过实例展示了如何在CContentViewController和RootViewController之间实现消息传递。
摘要由CSDN通过智能技术生成

最近又刚刚翻过头来写iPhone的代码


原来使用Xcode2版本,现在都4了

安装完Xcode4新建工程,我晕了.....(不解释了)


现在作为菜鸟,从头记笔记,先看看用处最多的delegate代理


首先是声明定义部分:

CContentViewController.h文件

@class CContentViewController;

@protocol CsContentViewDelegate

@required  //必需要实现的方法
- (void)CContentViewControllerDidFinish:(CContentViewController *)controller;


@end


@interface CContentViewController : UIViewController
{

  //成员变量
   
}

@property (assign, nonatomic)  id CContentViewDelegate delegate;

- (IBAction)back:(id)sender;

@end

CContentViewController.m文件

- (IBAction)back:(id)sender {
    //[self dismissModalViewControllerAnimated:YES];
    [self.delegate ChatsContentViewControllerDidFinish:self];
}

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值