<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)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: a色毛片免费视频| 亚洲精品国产美女久久久| 拍拍拍无挡免费视频网站| 亚洲精品天堂在线观看| 亚洲人精品午夜射精日韩| 国产精品无码一二区免费| 1000部夫妻午夜免费| 99久久免费国产特黄| 无套内谢孕妇毛片免费看看| 亚洲久悠悠色悠在线播放| 亚洲美女aⅴ久久久91| 精品国产亚洲一区二区三区| 亚洲国产午夜福利在线播放| 好男人看视频免费2019中文| 日本片免费观看一区二区| 中文字幕无码日韩专区免费| 一个人免费观看www视频| 精品无码专区亚洲| 在线观看亚洲AV日韩A∨| 亚洲国产精品日韩在线观看| 亚洲第一成年男人的天堂| 亚洲乳大丰满中文字幕| 久久亚洲精品无码观看不卡| 亚洲精品一级无码中文字幕| 国产jizzjizz免费视频| 小小影视日本动漫观看免费| 好吊妞在线新免费视频| 在线观看免费人成视频色| 91久久精品国产免费直播| 5555在线播放免费播放| 91麻豆国产免费观看| 97青青草原国产免费观看| 暖暖免费日本在线中文| 最近国语视频在线观看免费播放| 久久久久久av无码免费看大片| 日本高清不卡中文字幕免费| 一级午夜a毛片免费视频| 国产精品福利片免费看| 久久免费国产精品| 在线观看片免费人成视频播放| a级毛片高清免费视频|