LinkedIn SDK iOS快速 [英] LinkedIn SDK ios swift

查看:85
本文介绍了LinkedIn SDK iOS快速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Swift将iOS中的LinkedIn SDK集成

I am trying to integrate LinkedIn SDK in iOS using swift

我在Objective-C中找到了以下代码( https://developer.linkedin. com/docs/signin-with-linkedin )

I found the below code in objective-C (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
    }];
]}

如何将其转换为快速内容.

How to convert this to 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的了解来尝试解决这个问题.

This (I think its correct) is the translated version. I don't know Objective-C, I just used my knowledge of Swift to try and figure this out.

您了解闭包了吗?如果没有,我不建议使用像LinkedIn这样的SDK,因为它们依赖于闭包来处理许多网络请求.我会查看 Treehouse Inc. ,这是一个编码课程站点,提供了有关Swift中闭包的出色课程(以及许多其他东西).

Have you learned about closures yet? If not, I don't recommend using SDKs like the LinkedIn one because they rely on closures for many networking requests. I'd check out Treehouse Inc., a coding course site which offers great courses on closures in Swift (along with a bunch of other stuff).

这篇关于LinkedIn SDK iOS快速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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