What is a quot;delegatequot; in Objective C#39;s iPhone development?(什么是“代表?在 Objective C 的 iPhone 开发中?)
问题描述
Objective C 的 iPhone 开发中的委托"是什么?
What is a "delegate" in Objective C's iPhone development?
推荐答案
查看此讨论
委托允许一个对象在事件发生时向另一个对象发送消息.例如,如果您使用 NSURLConnection 类从网站异步下载数据.NSURLConnection 有三个常见的委托:
A delegate allows one object to send messages to another object when an event happens. For example, if you're downloading data from a web site asynchronously using the NSURLConnection class. NSURLConnection has three common delegates:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
当 NSURLConnection 遇到失败、成功完成或收到来自网站的响应时,将分别调用这些委托中的一个或多个.
One or more of these delegates will get called when NSURLConnection encounters a failure, finishes successfully, or received a response from the web site, respectively.
这篇关于什么是“代表"?在 Objective C 的 iPhone 开发中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么是“代表"?在 Objective C 的 iPhone 开发中?
基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
