如何在sw中将anyobject类型转换为int [英] How to convert anyobject type to int in sw

查看:152
本文介绍了如何在sw中将anyobject类型转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这样的字典数组中搜索一个键。





我得到了正确的结果值。但我的问题是我想将此结果转换为Int值。我尝试了几种方法,但没有帮助。



这是我试过的一种方式,但这个数字检查条件不成功。







我该怎么做?请帮我。谢谢



我尝试过:



I am searching a key in an Array of dictionary like this.


I am getting the correct value for result. But my problem is I want to convert this result in to Int value. I tried several ways but didnt help.

This is one way I tried,, but this number checking condition doesn't get true.



How can I do this? Please help me. Thanks

What I have tried:

if let result = self.lasrIDArray.flatMap({$0["\(self.selectedTitle)"]}).first  {
                print("-------RESULT------\(result)") //->title of the other
                if let number=result as? NSNumber
                {
                     let tag=number.integerValue
                     let currentScroll=self.view.viewWithTag(Int(api.selectedCatID)!) as! UIScrollView
                     let lastImgVw=currentScroll.viewWithTag(tag) as! UIImageView
                     print("-------LASTIMG ORIGIN------\(lastImgVw.frame.origin.y)")
    
                }

推荐答案

0 [< span class =code-string> \(self.selectedTitle)]})。first {
print( -------结果------ \(结果) // - >其他的标题
if 让number =结果为? NSNumber
{
let tag = number.integerValue
let currentScroll = self.view.viewWithTag(Int(api.selectedCatID)!)as! UIScrollView
让lastImgVw = currentScroll.viewWithTag(tag)为! UIImageView
print( ------- LASTIMG ORIGIN ------ \( lastImgVw.frame.origin.y)

}
0["\(self.selectedTitle)"]}).first { print("-------RESULT------\(result)") //->title of the other if let number=result as? NSNumber { let tag=number.integerValue let currentScroll=self.view.viewWithTag(Int(api.selectedCatID)!) as! UIScrollView let lastImgVw=currentScroll.viewWithTag(tag) as! UIImageView print("-------LASTIMG ORIGIN------\(lastImgVw.frame.origin.y)") }


这篇关于如何在sw中将anyobject类型转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆