您的位置:首页 > 移动开发 > IOS开发

IOS 通知

2013-10-17 23:07 337 查看
1.注册通知

//通知
向通知中心注册了一条名为ChangeTextNotification的通知。

[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(changeTextContent:)
name:@"ChangeTextNotification"
object:nil];

2.发送通知

//利用通知调用更改text的方法

[[NSNotificationCenter
defaultCenter] postNotificationName:@"ChangeTextNotification"
object:_textField.text];

3.通知所执行的方法

//利用通知执行方法
- (void)changeTextContentByNotification:(NSNotification *)notification
{

id text = notification.object;

_helloField.text = text;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: