'NSString的!' 不能转换为'String'; 你的意思是用'as!' 迫使低垂?

use*_*935 2 ios swift

码:

 var strCategIds = ""

    for(var i = 0; i < arrCateName.count; i++){
            var prCate:PropCategory = arrCateName.objectAtIndex(i) as! PropCategory
            if(prCate.bSelected == true){
                    strCategIds =  strCategIds + prCate.strCategoryId as! String!

            }
        }
Run Code Online (Sandbox Code Playgroud)

这个错误意味着什么?我花了很多时间在它上面但没有成功.任何帮助都会受到赞赏.谢谢你提前

rin*_*aro 6

strCategIds + prCate.strCategoryId as! String!
Run Code Online (Sandbox Code Playgroud)

编译为

(strCategIds + prCate.strCategoryId) as! String!
Run Code Online (Sandbox Code Playgroud)

相反,我认为你应该:

strCategIds + (prCate.strCategoryId as! String)
Run Code Online (Sandbox Code Playgroud)