My task is picking files
from iCloud
and it's url,title,etc.
,then appending into item array
. After that, I am taking each values with help of struct
and listing in tableView
.
Here, one thing I need to understand, how to validate
user picked files already exist or not into my array. If exist, I don't allow to append their file with alert
message.
// Array Declaration
var items = [Item]()
var tableArray = [Item]()
// Values appending into my array
items.append(Item(url: fileurl, title: filename, exten: fileextension, size: string))
// Tableview data load
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell
let item = tableArray[indexPath.row]
if tableArray.count > 0 {
cell.name_label_util.text = item.title
cell.size_label_util.text = item.size
}
return cell
}
Item
structure Equatable and check if your array contains it before appending