我在mutablearray中添加了字符串对象:
let photoArray: NSMutableArray = []
for photo in media {
photoArray.add("\(photo.fileName ?? "")")
}
然后我得到一个输出:
<__NSSingleObjectArrayI 0x1c02069e0>(
(
"Car",
"Dog",
"Tree"
)
)
但我想要这个:
(
"Car",
"Dog",
"Tree"
)
有没有办法得到那样的输出?
答案 0 :(得分:4)
试试这个,它对我很有用。
var photoArray = [String]()
for photo in media {
let fileName = photo.fileName ?? ""
print("fileName - \(fileName)")
photoArray.append(fileName)
}
print("\n\n** photoArray - \n\(photoArray)")
result = [“Car”,“Dog”,“Tree”]