我正在尝试从Youtube API获取信息,并且无法将项目投射到我的阵列中。这就是我得到的。
我正在建立我的公共阵列......
var videoId = [String]()
以下是代码从字典的jsonresponse中删除的内容...
for var i=0; i<items.count; ++i
{
if let idDict = items[i]["id"] as? NSDictionary
{
let id = idDict["videoId"] as! String
//self.videoId = [id]
self.videoId.append(id)
print(self.videoId)
这是我的回答.......
["Z32Y5MkdICQ"]
["Z32Y5MkdICQ", "UrNb397wS-A"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A", "DmOvILJAYK8"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A", "DmOvILJAYK8", "E5svXAZ9-Qk"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A", "DmOvILJAYK8", "E5svXAZ9-Qk", "vYH6Sw3A-BA"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A", "DmOvILJAYK8", "E5svXAZ9-Qk", "vYH6Sw3A-BA", "mgZz4L1UmxE"]
["Z32Y5MkdICQ", "UrNb397wS-A", "vzwoJ10UyO0", "jBmkCoiHC2c", "PzpLkcfBe-A", "DmOvILJAYK8", "E5svXAZ9-Qk", "vYH6Sw3A-BA", "mgZz4L1UmxE", "Gh4fgkiUi18"]
当然,我想要的是最后一个10 videoId
的数组。我怎么能得到这个?另外,如果你知道..你可以在tableview:cellForRowAtIndexPath
内给我正确的铸造过程吗?
答案 0 :(得分:4)
将你的打印带出循环!你没有得到一堆不同的数组,你只是在每次循环时打印相同的数组并附加一个新项目。
(?:(\/\*(.){32}\*\/).*(\n)?\1)|(?:(<!--(.*)-->).*(\n)?\1)