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

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

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

    pingpang

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      21 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

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

    首先創(chuàng)建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中實(shí)現(xiàn)委托:
    [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中實(shí)現(xiàn):
    [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
    調(diào)用添加:
    [java] view plaincopyprint?
    test = [[FunctionTest alloc]init];  
        test.delegate = self;  
          
        [test func1];  
        [test func2];  

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

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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲 欧洲 日韩 综合在线| 亚洲国产成人精品久久| 亚洲免费日韩无码系列| 色www永久免费视频| 在线视频精品免费| 久久久高清免费视频| 好先生在线观看免费播放| 成人免费午夜在线观看| 无码人妻久久一区二区三区免费丨| 国产精品免费无遮挡无码永久视频| 男的把j放进女人下面视频免费| 日韩视频在线观看免费| 5555在线播放免费播放| 免费电视剧在线观看| 国产老女人精品免费视频| 亚洲精品无码av天堂| 1区1区3区4区产品亚洲| 亚洲丶国产丶欧美一区二区三区| 色五月五月丁香亚洲综合网| 理论秋霞在线看免费| 青青草无码免费一二三区| 国产国产人免费视频成69大陆| 亚洲国产精品一区二区第一页| 亚洲综合小说另类图片动图| 午夜免费国产体验区免费的| 久久精品成人免费看| 免费乱理伦在线播放| 亚洲黄色在线视频| 国产免费一区二区三区免费视频| 最近2019免费中文字幕6| 亚洲婷婷五月综合狠狠爱| 亚洲欧美不卡高清在线| 24小时免费直播在线观看| 久久亚洲国产精品五月天| 亚洲精华液一二三产区| 久久夜色精品国产噜噜亚洲a| 免费无码av片在线观看| 国产av无码专区亚洲av果冻传媒| 在线观看亚洲精品专区| 国产在线观看免费完整版中文版 | 亚洲美女在线国产|