OC高效率52之用前缀避免命名空间冲突
2016-02-15 00:00
489 查看
摘要: 接口与API设计
#import <Foundation/Foundation.h> /// Apple宣称其保留使用所有“两字母前缀”的权利,自己选用的前缀应该是三个字母 @class EocSoundPlayer; @protocol EOCSoundPlayerDelegate <NSObject> //播放完毕回调 -(void) soundPlayerDidFinish:(EocSoundPlayer *)player; @end @interface EocSoundPlayer : NSObject @property (nonatomic , weak) id <EOCSoundPlayerDelegate> delegate; -(id) initWithURL:(NSURL *)url; -(void) playSound; @end #import "EocSoundPlayer.h" #import <AudioToolbox/AudioToolbox.h> void completion (SystemSoundID ssID,void *clientData) { EocSoundPlayer *player = (__bridge EocSoundPlayer *)clientData; if ([player.delegate respondsToSelector:@selector(soundPlayerDidFinish:)]) { [player.delegate soundPlayerDidFinish:player]; } } @implementation EocSoundPlayer { SystemSoundID _systemSoundID; } -(id)initWithURL:(NSURL *)url { if ((self = [super init])) { AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &_systemSoundID); } return self; } -(void) dealloc { AudioServicesDisposeSystemSoundID(_systemSoundID); } -(void)playSound { AudioServicesAddSystemSoundCompletion(_systemSoundID, NULL, NULL,completion,(__bridge void *)self), AudioServicesPlaySystemSound(_systemSoundID); } @end
相关文章推荐
- 【Kafka】运维
- 【Git】远程仓库
- 你是个成熟的职场人么?
- 天下数据支招如何保证云计算信息安全
- mysql中INSERT INTO… ON DUPLICATE KEY UPDATE用法
- 创业的第一百二十一天
- Scrapy安装
- 使用hadoop mapperreduce来统计大文件的行数-续1
- 运行hadoop自带的wordcount例子
- 编译hadoop自带的wnordcout例子
- 前台慢加密实现
- 设计模式之禅-第一篇
- Kendo AUTOCOMPLETE
- android 学习 day day up
- 全文检索(一)
- 永中Office电子表格两行或两列互换宏
- OpenTSDB logo开源监控系统 OpenTSDB
- Linux 系统性能优化
- bigdata hadoop 面试问题一
- HDFS