无法在自定义类swift ios中将项添加到自定义类数组

时间:2014-09-23 07:14:35

标签: ios swift

我是swift的新手

我正在尝试将项目附加到infopacks数组,但不知何故没有项目添加到数组中

import UIKit

class Tag: NSObject {

    var id:Int?
    var infopacks = [InfoPack]()

    init(tag :AnyObject)
    {
        self.id = (tag["id"] as NSNumber).integerValue
        if(tag["infopacks"] != nil)
        {
            var tmpInfopackArr:NSMutableArray = tag["infopacks"] as NSMutableArray
            if(tmpInfopackArr.count>0)
            {
                for index in 0...tmpInfopackArr.count - 1
                {
                    var infopack:InfoPack = InfoPack(infopack: tmpInfopackArr[index])
                    **self.infopacks.append(infopack)**
                }
            }
        }

    }
}

非常欢迎任何帮助或建议

0 个答案:

没有答案