LinkedIn SDK ios swift
我正在尝试使用swift在iOS中集成LinkedIn SDK
我在Objective-C中find了下面的代码( https://developer.linkedin.com/docs/signin-with-linkedin )
NSString *url = [NSString initWithString:@"https://api.linkedin.com/v1/people/~"]; if ([LISDKSessionManager hasValidSession]) { [[LISDKAPIHelper sharedInstance] getRequest:url success:^(LISDKAPIResponse *response) { // do something with response } error:^(LISDKAPIError *apiError) { // do something with error }]; ]}
如何将其转换为swift。
我很新,很快
var url = NSString(string:"https://api.linkedin.com/v1/people/~") if LISDKSessionManager.hasValidSession { LISDKAPIHelper.sharedInstance().getRequest(url, success: { response in //Do something with the response }, error: { error in //Do something with the error }) }
这(我认为是正确的)是翻译版本。 我不知道Objective-C,我只是用我的Swift知识来尝试解决这个问题。
你有没有学习closures? 如果没有,我不推荐使用像LinkedIn这样的SDK,因为它们依赖于closures许多networking请求。 我会检查Treehouse Inc. ,一个编码课程网站,它提供关于在Swift中closures的伟大课程(以及其他一些东西)。
var url = "https://api.linkedin.com/v1/people/~" if LISDKSessionManager.hasValidSession() { try? LISDKAPIHelper.sharedInstance().getRequest(url, success: {(_ response: LISDKAPIResponse) -> Void in // do something with response }) }
这是迅速的4
- 为什么我不能embedded我的自定义框架?
- UIAccessibilityLayoutChangedNotification和UIAccessibilityScreenChangedNotification之间的实际区别?
- 寻找比IPFW更好的解决scheme来减缓互联网连接
- 保留UITableViewCell选择状态
- WWDC 2016聚焦:iOS 10国际化和本地化
- 生成崩溃而不是.crash文件的“JetsamEvent-2015-03-18-151504.ips”文件
- 将UITableView添加到现有的ViewController
- XCode PhoneGap本地化
- 我可以从XCAssets包中获取NSURL吗?