简体   繁体   English

'NSString的!' 不能转换为'String'; 您是要使用“ as!”吗? 强迫垂头丧气?

[英]'NSString!' is not convertible to 'String'; did you mean to use 'as!' to force downcast?

Code: 码:

 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!

            }
        }

What is this error meaning?I have spent lot of time on it.but no success.any help will be appreciated.thanks in advance 这个错误是什么意思?我花了很多时间在上面,但没有成功,任何帮助将不胜感激。

strCategIds + prCate.strCategoryId as! String!

is compiled as 被编译为

(strCategIds + prCate.strCategoryId) as! String!

Instead, I think you should: 相反,我认为您应该:

strCategIds + (prCate.strCategoryId as! String)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 斯威夫特 - &#39;AnyObject!&#39; 不能转换为&#39;ViewController&#39;; 你的意思是用&#39;as!&#39; 迫使低垂? - Swift - 'AnyObject!' is not convertible to 'ViewController'; did you mean to use 'as!' to force downcast? “ ValidationError”不能转换为“ Error”;您是要使用“ as!”吗? 强迫垂头丧气? - 'ValidationError' is not convertible to 'Error';did you mean to use 'as!' to force downcast? “ NSData”不能隐式转换为“ Data”; 您是要使用“ as”进行显式转换吗? - 'NSData' is not implicitly convertible to 'Data'; did you mean to use 'as' to explicitly convert? 从“UIViewController?”向下转型? &#39;UIViewController&#39; 只解开可选项; 你的意思是使用“!”? - Downcast from 'UIViewController?' to 'UIViewController' only unwraps optionals; did you mean to use '!'? 是否从“ CLLocation”下调? 到“ CLLocation”仅解开可选部分; 您是要使用&#39;!&#39;吗? - Downcast from 'CLLocation?' to 'CLLocation' only unwraps optionals; did you mean to use '!'? 这个错误的原因是什么:“NSIndexPath”不能隐式转换为“IndexPath”; 您的意思是使用 &#39;as&#39; 来显式转换吗?” - What is the reason for this error: “NSIndexPath' is not implicitly convertible to 'IndexPath'; did you mean to use 'as' to explicitly convert?” 串? 不能转换为“ NSString” - String? is not convertible to 'NSString' “ [String]”不可转换为“ [NSString]” - '[String]' is not convertible to '[NSString]' Swift:NSString无法转换为“字符串” - Swift: NSString not convertible to 'String' Swift 3 &#39;[UIApplicationLaunchOptionsKey : Any]? 不可转换为 &#39;[String : NSString]&#39; - Swift 3 '[UIApplicationLaunchOptionsKey : Any]?' is not convertible to '[String : NSString]'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM