将对象添加到 nsmutablearray swift

Adding objects to nsmutablearray swift

我在可变数组中添加了字符串对象:

let photoArray: NSMutableArray = []
for photo in media {
    photoArray.add("\(photo.fileName ?? "")")
}

然后我得到如下输出:

<__NSSingleObjectArrayI 0x1c02069e0>(
  (
     "Car",
     "Dog",
     "Tree"
  )
)

但我想要这个 :

(
     "Car",
     "Dog",
     "Tree"
)

有没有办法得到这样的输出?

试试这个,它非常适合我。

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"]