OC9_代理正向传值
//
// ProtectedDeleagate.h
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h> @protocol ProtectedDeleagate <NSObject>
- (void)bark:(NSInteger)count; @end //
// Person.h
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h>
#import "ProtectedDeleagate.h" @interface Person : NSObject
//{
// __unsafe_unretained id <ProtectedDeleagate>_delegate;
//}
@property (nonatomic,assign)id <ProtectedDeleagate>delegate; @property (nonatomic)NSInteger count; - (void)go; @end //
// Person.m
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "Person.h" @implementation Person - (void)go
{
[_delegate bark:self.count];
}
@end //
// Dog.h
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h>
#import "ProtectedDeleagate.h" @interface Dog : NSObject <ProtectedDeleagate> @end //
// Dog.m
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "Dog.h" @implementation Dog - (void)bark:(NSInteger)count
{
for (NSInteger i=; i<count; i++) {
NSLog(@"Wang wang wang ...");
}
} @end
//
// main.m
// OC9_代理正向传值
//
// Created by zhangxueming on 15/6/24.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h>
#import "Dog.h"
#import "Person.h" int main(int argc, const char * argv[]) {
@autoreleasepool {
Person *xiaoXin = [[Person alloc] init];
xiaoXin.count = ;
Dog *dog = [[Dog alloc] init];
xiaoXin.delegate = dog;
[xiaoXin go];
}
return ;
}
OC9_代理正向传值的更多相关文章
- 利用协议代理实现导航控制器UINavigationController视图之间的正向传值和反向传值
实验说明 (1)正向传值:比如A类里地值要传给B类用,就是我们先在A类中声明一个B类对象(当然B类头文件要import过来),然后把A类中得某个 值传递给B类中得某个值(所以需要在B类中先准备一个变量 ...
- OC10_代理反向传值
// // ProtectedDelegate.h // OC10_代理反向传值 // // Created by zhangxueming on 15/6/24. // Copyright (c) ...
- ios代理的使用,正向传值,逆向传值
#import <UIKit/UIKit.h> #import "SubViewController.h" @interface ViewController : UI ...
- iOS 代理反向传值
在上篇博客 iOS代理协议 中,侧重解析了委托代理协议的概念等,本文将侧重于它们在开发中的应用. 假如我们有一个需求如下:界面A上面有一个button.一个label.从界面A跳转到界面B,在界面B的 ...
- iOS-设计模式之代理反向传值
代理设计模式就是自己的方法自己不实现,让代理对象去实现. 可以让多个类实现一组方法. 委托模式的好处在于: 1.避免子类化带来的过多的子类以及子类与父类的耦合 2.通过委托传递消息机制实现分层解耦 代 ...
- Swift代理和传值
第一个视图控制器: import UIKit // 遵循协议 class ViewController: UIViewController,SecondVCDelegate { override fu ...
- ios 得用代理反向传值
应用场景:有时时候从界面A跳转到界面B,界面B在返回的时候须要将处理的结果传递给A. 实现思路:1,定义一个负责传值的协义,界面A拥有该协义属性,并实现该协义中的方法 2.界面B也拥有该协义属性(代理 ...
- nginx代理(正向代理和反向代理)
正向代理 是一个位于客户端和原始服务器(origin server)之间的服务器,为了从原始服务器取得内容,客户端向代理发送一个请求并指定目标(原始服务器),然后代理向原始服务器转交请求并将获得的内容 ...
- Apple Watch开发之界面之间的正向传值
主要分两种,一种是故事板中通过segue进行的传值,第二种是使用代码. 贴代码 24行代码是代码进行传值 35是故事板中的
随机推荐
- CF B. Kolya and Tandem Repeat
Kolya got string s for his birthday, the string consists of small English letters. He immediately ad ...
- iOS开发——多线程OC篇&多线程详解
多线程详解 前面介绍了多线程的各种方式及其使用,这里补一点关于多线程的概念及相关技巧与使用,相信前面不懂的地方看了这里之后你就对多线程基本上没有什么问题了! 1——首先ios开发多线程中必须了解的概念 ...
- direction:rtl demo
<style> body {font:14px/18px Consolas;} div { width:100px;padding:10px; margin:10px 0px 30px 0 ...
- 疑难杂症:NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.includeClassesUrl(Lcom/opensymphony/xwork2/util/finder/ClassLoaderInterface;)
严重: Exception starting filter struts2java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finde ...
- QMap与QHash
关联容器可以保存任意多个具有相同类型的项,且它们由一个键索引.Qt提供两个主要的关联容器类:QMap<K, T>和QHash<K, T>. QMap<K, T>是一 ...
- Google 推出全新的两步验证机制
近日 Google 在官方的 Apps Updates 博客公布了全新的两步验证功能--Google 提示,新的功能通过与 Google App 联动,进一步将验证确认工作缩减到仅有两步,同时支持 A ...
- Golang学习 - regexp 包
------------------------------------------------------------ // 函数 // 判断在 b(s.r)中能否找到 pattern 所匹配的字符 ...
- Find the Clones
Find the Clones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 6365 Accepted: 2375 D ...
- 经典的iptables shell脚本
PS:这个iptables脚本不错,很实用,根据实际应用改一下就可以自己用.分享出来,供大家来参考.原作者佚名.源代码如下: #!/bin/sh modprobe ipt_MASQUERADE mod ...
- Java基础知识强化之IO流笔记77:NIO之 Selector
Selector(选择器)是Java NIO中能够检测一到多个NIO通道,并能够知晓通道是否为诸如读写事件做好准备的组件.这样,一个单独的线程可以管理多个channel,从而管理多个网络连接. 1. ...