[英]How to Handle Fetched User's Location from FBSDK IOS swift
i got the user Location using FBSDK. 我使用FBSDK获得了用户位置。 Now I do not know how to seperate the information to get each part of information i am printing it in console and this is what get
现在我不知道如何分隔信息以获取信息的每个部分,我正在控制台中打印它,这就是
Optional({
id = 110855035610007;
name = "Rawalpindi, Pakistan";
})
how do i get "Rawalpindi" and "Pakistan" and store them in some variable according to Docs its returning a Struct i guess so i do not know how to handle that please guide me thanks 我如何获取“ Rawalpindi”和“巴基斯坦”并将它们存储在根据Docs返回的Struct 文件中,所以我不知道该如何处理,请指导我,谢谢
First thing, you have to create one responseDictionary and then store response in it. 首先,您必须创建一个responseDictionary,然后将响应存储在其中。
then you can get this name like, 那么你可以得到这个名字,
let str = self.responseDic.valueForKey("name") as? String
Then you can separate this string like, 然后,您可以将字符串分隔为
let arr : NSArray = str!.componentsSeparatedByString(",") as NSArray
print(arr.objectAtIndex(0))
print(arr.objectAtIndex(1))
Hope this way you will fix it. 希望以此方式您可以解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.