kingBook

导航

Object-c中的单例

#import <UIKit/UIKit.h>
@interface UniAudioPlayer:NSObject{
}
+(UniAudioPlayer*) getInstance;
@end
#import "UniAudioPlayer.h"

@implementation UniAudioPlayer
+ (UniAudioPlayer *) getInstance {
    static dispatch_once_t once;
    static UniAudioPlayer *instance;
    dispatch_once(&once, ^ { instance = [[UniAudioPlayer alloc] init]; });
    return instance;
}

@end

 

posted on 2017-04-06 11:00  kingBook  阅读(254)  评论(0编辑  收藏  举报