iOS方法作为属性传递
2015-12-25 17:41
381 查看
iOS中方法作为属性或者是参数进行传递,下边我是以代理方法为例。
.h中的代码让代理方法作为一个属性
@property(nonatomic,assign)SEL delegateSelect;
.m中的代码让delegate调用这个传过来的代理方法 传值用withObject:一个对象传递
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)
if ([self.delegate
respondsToSelector:self.delegateSelect]) {
NSMutableDictionary* dict = [[NSMutableDictionary
alloc]
init];
[dict setValue:[NSNumber
numberWithFloat:oldCoordinate.longitude]
forKey:@"longitude"];
[dict setValue:[NSNumber
numberWithFloat:oldCoordinate.latitude]
forKey:@"latitude"];
SuppressPerformSelectorLeakWarning([self.delegate
performSelector:self.delegateSelect
withObject:place.name
withObject:dict]);
}
.h中的代码让代理方法作为一个属性
@property(nonatomic,assign)SEL delegateSelect;
.m中的代码让delegate调用这个传过来的代理方法 传值用withObject:一个对象传递
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)
if ([self.delegate
respondsToSelector:self.delegateSelect]) {
NSMutableDictionary* dict = [[NSMutableDictionary
alloc]
init];
[dict setValue:[NSNumber
numberWithFloat:oldCoordinate.longitude]
forKey:@"longitude"];
[dict setValue:[NSNumber
numberWithFloat:oldCoordinate.latitude]
forKey:@"latitude"];
SuppressPerformSelectorLeakWarning([self.delegate
performSelector:self.delegateSelect
withObject:place.name
withObject:dict]);
}
相关文章推荐
- iOS显示GIF图片(3中方法)
- iOS开发封装一个可以响应超链接的label——基于RCLabel的交互扩展
- iOS可执行文件瘦身方法
- iOS把对象直接转化成NSDictionary或JSON
- IOS文件系统
- ios音量振动条
- iOS当期时间和日期选择器
- iOS简单的音效播放单例 (您可照搬代码)
- IOS开发——获取本地音频文件(属性/信息)
- IOS平台音频处理API介绍
- iOS 真机调试双击.cer证书
- iOS可变数组添加元素 以及可变数组操作
- iOS项目重构周记(一)
- iOS项目重构周记(二)
- iOS的三种多线程技术
- iOS开发笔记--连续跳转上层页面
- iOS从xib界面跳转到storyboard 中的界面和从storyboard中的界面跳转到另一个storyboard中的界面
- iOS--代码关联storyboard
- 处理动态类型的方法
- iOS 触摸事件五:手势处理器