![](/img/trans.png)
[英]share post on linkedin using ios swift 3 and linkedin sdk is not working
[英]LinkedIn SDK ios swift
我正在嘗試使用Swift將iOS中的LinkedIn SDK集成
我在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
}];
]}
如何將其轉換為快速。
我是新手
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的了解來嘗試解決這個問題。
您了解閉包了嗎? 如果沒有,我不建議使用像LinkedIn這樣的SDK,因為它們依賴於閉包來處理許多網絡請求。 我會去Treehouse Inc. ,這是一個編碼課程站點,其中提供了有關Swift中的閉包的出色課程(以及許多其他內容)。
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.