I am working on an audio-recording application. Each time I stop the recording, I need to add the recording filename to an array. Currently, only one element gets added and when I add the next element, I am not able to see the previous element that had been added. Am I missing something?
func pushDummyUploadCell(pendingUploadModel: String) {
var pendingUploadModels: [String] = []
if !queueAllFailedRecordings {
pendingUploadModels.append(pendingUploadModel)
print("Queue:",pendingUploadModels.count,"elements:",[pendingUploadModels]) //each time returns 1
}
else {
pendingUploadModels = [pendingUploadModel]
}
}
I am calling this function once I stop the recording.
You just need to define your array as globle in your controller or class.
var pendingUploadModels: [String] = []
func pushDummyUploadCell(pendingUploadModel: String) {
if !queueAllFailedRecordings {
pendingUploadModels.append(pendingUploadModel)
print("Queue:",pendingUploadModels.count,"elements:",[pendingUploadModels]) //each time returns 1
}
else {
pendingUploadModels = [pendingUploadModel]
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.