I define a class in Swift like that:
class RecordedAudio: NSObject {
var title: String!
var filePathUrl: NSURL!
init(title: String, filePathUrl: NSURL) {
self.title = title
self.filePathUrl = filePathUrl
}
}
After that, I declare the global var of this one in controller
var recordedAudio: RecordedAudio!
And then, create the instance in this function:
func audioRecorderDidFinishRecording(recorder: AVAudioRecorder!, successfully flag: Bool) {
if(flag){
// save recorded audio
recordedAudio = RecordedAudio(title: recorder.url.lastPathComponent, filePathUrl: recorder.url)
...
But I got the error message in line I create the instance of RecordedAudio:
Value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'?
Could you help me this case? I am a beginner of Swift...