<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    pingpang

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      21 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

    寫了一個簡單的委托的試用測試:

    首先創建FunctionTest類,聲明委托:

    FunctionTest.h

    [java] view plaincopyprint?
    //  
    //  FunctionTest.h  
    //  DelegateDemo  
    //  
    //  Created by shx on 12-7-17.  
    //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.  
    //  
      
    #import <Foundation/Foundation.h>  
      
    @protocol FunctionTestDelegate;  
      
    @interface FunctionTest : NSObject  
    {  
        id<FunctionTestDelegate> delegate;  
    }  
    @property (nonatomic, assign)id<FunctionTestDelegate> delegate;  
    - (void)func1;  
    - (void)func2;  
    @end  
      
    @protocol FunctionTestDelegate <NSObject>  
      
    - (void)func3;  
    - (void)func4;  
      
    @end  

    FunctionTest.m
    [java] view plaincopyprint?
    //  
    //  FunctionTest.m  
    //  DelegateDemo  
    //  
    //  Created by shx on 12-7-17.  
    //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.  
    //  
      
    #import "FunctionTest.h"  
      
    @implementation FunctionTest  
      
    @synthesize delegate;  
      
    - (void)func1  
    {  
        NSLog(@"function 1 called");  
        [delegate performSelector:@selector(func3)];  
    }  
      
    - (void)func2  
    {  
        NSLog(@"function 2 called");  
        [delegate performSelector:@selector(func4)];  
    }  
    @end  

    在appdelegate中實現委托:
    [java] view plaincopyprint?
    //  
    //  AppDelegate.h  
    //  DelegateDemo  
    //  
    //  Created by shx on 12-7-17.  
    //  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.  
    //  
      
    #import <UIKit/UIKit.h>  
    #import "FunctionTest.h"  
      
    @class ViewController;  
      
    @interface AppDelegate : UIResponder <UIApplicationDelegate,FunctionTestDelegate>  
    {  
        FunctionTest *test;  
    }  
      
    @property (strong, nonatomic) UIWindow *window;  
      
    @property (strong, nonatomic) ViewController *viewController;  
      
    @end  
    AppDelegate.m中實現:
    [java] view plaincopyprint?
    #pragma mark -FunctionTestDelegate  
    - (void)func3  
    {  
        NSLog(@"function 3 calledns");  
    }  
    - (void)func4  
    {  
        NSLog(@"function 4 calledns");  
    }  




    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    調用添加:
    [java] view plaincopyprint?
    test = [[FunctionTest alloc]init];  
        test.delegate = self;  
          
        [test func1];  
        [test func2];  

    posted on 2012-07-17 21:26 往事隨風 閱讀(7329) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲中文字幕无码爆乳AV| 无码的免费不卡毛片视频| 国产精品亚洲а∨天堂2021 | 中国一级全黄的免费观看| 免费亚洲视频在线观看| 亚洲午夜精品久久久久久人妖 | 黄页视频在线观看免费| 毛片A级毛片免费播放| 国产AV无码专区亚洲AV毛网站| 亚洲Av高清一区二区三区| 三年片在线观看免费大全| 亚洲中文字幕无码亚洲成A人片| 中文字幕免费在线看线人动作大片 | 很黄很黄的网站免费的| 亚洲情a成黄在线观看| 成人免费777777被爆出| 亚洲宅男永久在线| 18禁成年无码免费网站无遮挡| 亚洲精品国产字幕久久不卡| 亚洲欧美国产欧美色欲| 四虎亚洲国产成人久久精品| eeuss影院ss奇兵免费com| 四虎影院免费视频| 亚洲美女在线观看播放| 大学生高清一级毛片免费| 国产亚洲精品美女| 毛片A级毛片免费播放| 一区二区三区在线免费观看视频 | 最近中文字幕大全中文字幕免费| 国产成人亚洲精品无码AV大片| 久久免费观看国产精品88av| 免费h片在线观看网址最新| 中中文字幕亚洲无线码| 亚洲福利精品电影在线观看| AAA日本高清在线播放免费观看| 国产精品亚洲mnbav网站| 99re在线视频免费观看| 久久精品国产亚洲一区二区| 日韩亚洲国产高清免费视频| 欧洲亚洲综合一区二区三区| 午夜老司机免费视频|