I am currently recording audio, but I do not understand the following rewriting.
If there is anyone who can tell me, I would appreciate your guidance.
// Is your model compatible with recording?
if([audioSession inputIsAvailable]) {
AudioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: & error;
}
if error {
NSLog(@"audioSession: %@%d%@", error domain , error code , [error userInfo] description);
}
How about like this?
(Verified by Xcode 7.0.1)
let audioSession=AVAudioSession.sharedInstance()
// InputIsAvailable is deprecated, so use inputAvailable
if audioSession.inputAvailable {
// NSError handling changed to do/try/catch on Swift2
do{
tryaudioSession.setCategory (AVAudioSessionCategoryPlayAndRecord)
} catchleterr{
// Swift2 uses print instead of NSLog
print("audioSession:\(err)")
}
}
© 2024 OneMinuteCode. All rights reserved.