返回首页
当前位置: 主页 > 手机mobile >

iphone 中消息傳送一般用法

时间:2010-07-28 11:11来源:未知 作者:sam.huang 点击:
Iphone有一個很強大的功能,就是消息傳送. 用法如下: [[NSNotificationCenter defaultCenter] postNotificationName:#(NSString *)aName# object:#(id)anObject# userInfo:#(NSDictionary *)aUserInfo#] 這是在object中廣播消息. 接
  

Iphone有一個很強大的功能,就是消息傳送.

用法如下:

[[NSNotificationCenter defaultCenter] postNotificationName:<#(NSString *)aName#> object:<#(id)anObject#> userInfo:<#(NSDictionary *)aUserInfo#>]

這是在object中廣播消息.

接收object用下面的方法接收:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateCounty:) name:COUNTY_PICKUP object:nil];

這個函數為object注冊了一個函數來響應消息的來到.這個函數就是updateCounty:

接收object要取消監聽,當這個object release時.

[[NSNotificationCenter defaultCenter] removeObserver:self name:COUNTY_PICKUP object:nil];

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
发布者资料
amw 查看详细资料 发送留言 加为好友 用户等级:高级会员 注册时间:2009-03-30 13:03 最后登录:2012-01-17 11:01
推荐内容