在nsmutable数组的情况下,找不到接受所提供参数的'subscript'的重载

时间:2015-09-07 07:10:09

标签: swift nsmutablearray

我是Swift的新手,你能不能告诉我为什么会发生这些错误

{
var profArr : NSMutableArray = NSMutableArray()


for index in 1...<profArr.count
        {
            var joomlaID : NSString = [dbManager?.getZoomlaID(profArr[index]["firmUserId"] as String)];  

// while using this in loop getting **could not find overload**  error.
        }



func getZoomlaID (firmUser : NSString) -> NSString
    {
        var zoomlaId : NSString

        var dbPath: AnyObject? = NSUserDefaults.standardUserDefaults().valueForKey("dbPath")

        var db = FMDatabase(path: dbPath as! String)

        db?.open()

        if var rsltSet : FMResultSet! = db!.executeQuery("Select JoomlaUserID From org_firm_users where FirmUserID like ('\(firmUser)')",  withArgumentsInArray: nil)  //Here again getting error Unprintable ASCII character.
        {
            while (rsltSet.next())
            {
                print(rsltSet.resultDictionary())

                zoomlaId = (rsltSet.resultDictionary() as NSDictionary).valueForKey("JoomlaUserID") as! NSString     
            }
        }

        else
        {
            println("select failed: \(db.lastErrorMessage())")
        }

        db?.close()

        return zoomlaId
    }
}

1 个答案:

答案 0 :(得分:0)

for index in 1...<profArr.count行中添加了一个不需要的.<循环声明,它应该是这样的:for index in 1..profArr.count

...表示从 - 到包含,..表示从 - 到非包含。

e.g。 1..3表示1,2,3但1..3表示1,2