Document Outline in Xcode
Model View Controller
view(UIView, UILabel, UIButton), controller, model
AutoLayout Basics
@IBOutlet weak var recordButton: UIButton! @IBOutlet weak var recordingLabel: UILabel! @IBOutlet weak var resumeButton: UIButton! @IBOutlet weak var resumeLabel: UILabel! @IBOutlet weak var pauseButton: UIButton! @IBOutlet weak var pauseLabel: UILabel! @IBOutlet weak var stopButton: UIButton! @IBOutlet weak var stopLabel: UILabel! @IBOutlet func recordButtonPressed(sender: UIButton){ // ... }
ViewController and Multiple Views
Not Running, Inactive, Active, Background, Suspended
Audio in iOS
Pitch Perfect App, AVFoundation, Core Audio, Audio Hardware
import AVFoundation class ViewController: UIViewController { var audioRecorder: AVAudioRecorder! @IBAction func recordAudio(_ sender: AnyObject){ recordingLabel.text = "Recording in progress" stopRecordingButton.isEnabled = true recordButton.isEnabled = false let dirPath = NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask, true)[0] as String let recordingName = "recordedVoice.wav" let pathArray = [dirPath, recordingName] let filePath = URL(string: pathArray.joined(separator: "/")) let session = AVAudioSession.sharedInstance() try! session.setCategory(AVAudioSessionCategoryPlayAndRecord, with:AVAudioSessionCategoryOptions.defaultToSpeaker) try! audioRecorder = AVAudioRecorder(url: filePath!, settings: [:]) audioRecorder.isMeteringEnabled = true audioRecorder.prepareToRecord() audioRecorder.record() } }