let item = event?.feed_category
item?.forEach({ items in
arr.append(items.title ?? "")
})
lblEventCategory.text = arr //this line incorrect
In this way, I print my array in the array, but how can I show it to the user by putting a comma between them in the label? Like this; technology, event, founder
CodePudding user response:
An array of strings can be joined by ,
using:
arr.joined(separator: ",")
Refer: https://developer.apple.com/documentation/swift/array/joined(separator:)-5do1g
CodePudding user response:
since your array, arr
may contain empty string ""
, you may want to remove them, using this approach:
print("----> arr: \(arr.filter{!$0.isEmpty}.joined(separator: ","))")