zoukankan      html  css  js  c++  java
  • 通知postNotificationName 消息传递详解

    1.定义消息创建的关联值 也就是找到方法的标志

    NSString *const GameToIPhoneNotification = @"GameToIPhoneNotification"; GameToIPhoneNotification变量,@"GameToIPhoneNotification"这个值存于通知中心中,信息中心通过这个值来识别变量

    1.注册一个消息中心

    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

    [center addObserver:self selector:@selector(onToIphone:) name:GameToIPhoneNotification object:nil];

    -(void)onToIphone:(NSNotification*)notify :这个方法是接受到GameToIPhoneNotification这个通知所调用的方法

    2.调用信息

    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];

    [center postNotificationName:GameToIPhoneNotification object:nil userInfo:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:SMSRecommendNotification] , @"actcode",nil]];

    [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:SMSRecommendNotification] 这个是传递给-(void)onToIphone:(NSNotification*)notify 的参数。

     转自http://blog.csdn.net/zu12jing/article/details/5772301

  • 相关阅读:
    Design pattern
    ArcSDE 快速入门
    struts2中s:select标签的使用
    CreateProcess error=87
    在DOS下添加用户
    加载SpringContext文件的方式
    svnkit获取svn相关信息
    Bat命令(管道与组合)
    JBOSS中使用RMI不能连接服务器的原因
    HTML中滚动条的样式设置
  • 原文地址:https://www.cnblogs.com/jiangshiyong/p/2886704.html
Copyright © 2011-2022 走看看