[英]Adding objects to nsmutablearray swift
I added the string objects inside the mutablearray : 我在mutablearray中添加了字符串对象:
let photoArray: NSMutableArray = []
for photo in media {
photoArray.add("\(photo.fileName ?? "")")
}
Then I get an output like: 然后我得到如下输出:
<__NSSingleObjectArrayI 0x1c02069e0>(
(
"Car",
"Dog",
"Tree"
)
)
But I want this : 但是我想要这个:
(
"Car",
"Dog",
"Tree"
)
Is there any way to get the output like that? 有什么办法可以得到这样的输出吗?
Try this, it works for me perfectly. 试试这个,它对我来说很完美。
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"]
结果= [“汽车”,“狗”,“树”]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.