# 초기화하기

Wepin iOS 로그인 라이브러리를 초기화하는 방법은 다음과 같습니다.&#x20;

WepinLogin 인스턴스를 생성하기 전에, App ID와 App Key를 WepinLoginParams 객체에 다음과 같이 전달해 주세요.

```swift
let initParam = WepinLoginParams(appId: appId, appKey: appKey)
```

이전에 생성한 WepinLoginParams를 전달하여 WepinLogin 인스턴스를 생성해 주세요.

```swift
var wepin = WepinLogin(initParam);
```

WepinLogin 인스턴스를 생성한 후, 초기화를 진행하기 위해 `initialize` 메서드를 호출하세요.

```swift
await wepin!.initialize()
```

### Example

```swift
let appKey: String = "Wepin-App-Key"
let appId: String = "Wepin-App-ID"
var wepin: WepinLogin? = nil
let initParam = WepinLoginParams(appId: appId, appKey: appKey)
wepin = WepinLogin(initParam)
// Call initialize function
do{
    let res = try await wepin!.initialize()
    self.tvResult.text = String("Successed: " + String(res!))
} catch (let error){
    self.tvResult.text = String("Faild: \(error)")
}
```

## isInitialized

`isInitialized` 메서드를 사용하여 WepinLogin 인스턴스가 올바르게 초기화되었는지 확인할 수 있습니다. 반환값은 다음과 같습니다:

* \<Bool>\
  초기화가 정상적으로 잘 된 경우 **true** , 실패한 경우 **false** 를 반환합니다.

```swift
let result = wepin!.isInitialized()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/init.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
