// completionBlock在AFURLConnectionOperation中被手动的设置为nil来打破保留周期。
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
self.completionBlock = ^ {
...
};
#pragma clang diagnostic pop
- 2、手机系统时间显示佛教或日本日历后,显示时间错误问题
#ifdef __IPHONE_8_0
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];//根据Identifer获取公历
#else
calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];//根据Identifer获取公历
#endif
calendar.timeZone = [NSTimeZone localTimeZone];//消除时区差异
calendar.locale = [NSLocale currentLocale];//消除本地化差异,本地化包括语言、表示的日期格式等
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.calendar = calendar;
static pthread_mutex_t _sharedDebugLock;
pthread_mutex_lock(&_sharedDebugLock);
...
pthread_mutex_unlock(&_sharedDebugLock);
dispatch_semaphore_t framesLock = dispatch_semaphore_create(1);
dispatch_semaphore_wait(framesLock, DISPATCH_TIME_FOREVER);
...
dispatch_semaphore_signal(framesLock);
__weak typeof(self) weakSelf = self;
self.testObject.testCircleBlock = ^{
__strong typeof (weakSelf) strongSelf = weakSelf;
[strongSelf doSomething];
};
- 5、蓝牙耳机问题
终端报AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port HiVi AW-71 (type: BluetoothHFP)
原因:为了调优app设置,以更好的进行录音录像,从iOS7
开始,在默认情况下,AVCaptureSession
会使用app的AVAudioSession,并对其进行修改。这样,会发出AVAudioSessionInterruptionNotification
和AVAudioSessionRouteChangeNotification
通知。在录制视频时,如果前后台切换,就可能会发出这样的通知,在接收到AVAudioSessionInterruptionNotification
通知时,在中断开始时暂停音乐播放,在中断结束时开启音乐播放。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleInterruption:)
name:AVAudioSessionInterruptionNotification object:nil];
- (void)handleInterruption:(NSNotification*)notification {
NSDictionary* userInfo = notification.userInfo;
if([userInfo[AVAudioSessionInterruptionTypeKey] intValue] == AVAudioSessionInterruptionTypeBegan) {
[self.musicPlayer pause];
} else {
[self.musicPlayer play];
}
}
#define kSCRecorderRecordSessionQueueKey "SCRecorderRecordSessionQueue"
dispatch_queue_t sessionQueue = dispatch_queue_create("me.corsin.SCRecorder.RecordSession", nil);
dispatch_queue_set_specific(sessionQueue, kSCRecorderRecordSessionQueueKey, "true", nil);
dispatch_set_target_queue(sessionQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
//判断当前执行队列是否为sessionQueue队列
+ (BOOL)isSessionQueue {
return dispatch_get_specific(kSCRecorderRecordSessionQueueKey) != nil;
}
celi():对一个数进行向上取整
floor():对一个数进行向下取整
round():四舍五入取整。