首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

AppDelegat种及协议

2012-08-21 
AppDelegat类及协议 iOS学习总结—NO.2_AppDelegat类及协议一、Main函数main.m 主函数:[AppDelegat class]

AppDelegat类及协议

 

iOS学习总结—NO.2_AppDelegat类及协议

一、Main函数

main.m 主函数:

AppDelegat种及协议

[AppDelegat class] 返回类型

NSStringFromClass 返回字符串,返回类的名字

二、AppDelegate类

1.AppDelegate.m 程序的入口(方法):

AppDelegat种及协议

系统自动调用此方法。

参数:

1)UIApplication

2)NSDictionary 

2.AppDelegate.h (头文件)

1)@interface AppDelegate : UIResponder <UIApplicationDelegate>

<>中是协议(哪个类使用必须实现这个协议的方法)

此协议与此类的父类无关

2)创建协议:

AppDelegat种及协议

AppDelegat种及协议

AppDelegat种及协议

2.1)TestDelegate.h (协议头文件)

【自己写两个方法】

AppDelegat种及协议

实现以上方法:

回到AppDelegate.h头文件

@interface AppDelegate : UIResponder <UIApplicationDelegate>

此类必须遵守此协议 使用此协议的方法。

使用多个协议:

使用协议必须包含此协议的头文件,多个协议之间用逗号隔开。

AppDelegat种及协议

创建一个新类(MyUIControl类)

在MyUIControl.m 中实现 TestDelegate 协议

AppDelegat种及协议

选择AppDelegate.m

AppDelegat种及协议

在AppDelegate 包含刚才新建的类与新建的协议

AppDelegat种及协议

创建一个新类:(DelegateUseTest类)

DelegateUseTest.h(头文件)

AppDelegat种及协议

====待续====更新时间未知

本文章介绍的不齐全,大家可以发表评论补充或发送电子邮件给作者。

Mail:superdeveloper@qq.com

 

热点排行