> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 同时加载多个广告

> 要同时准备多种格式，并发地请求并加载它们。

要同时准备多种格式，并发地请求并加载它们。每种格式并行请求和渲染，某种格式没有广告不会影响其他格式：

```swift theme={null}
func prepare(_ format: AdFormat) async -> VideoAd? {
    do {
        let ad = try await ads.format(format)
        try await ad.load()
        ad.delegate = self
        return ad
    } catch {
        return nil                     // 这次该格式无填充
    }
}

async let overlay = prepare(.overlay)
async let pause = prepare(.pause)
async let linear = prepare(.linear)
(overlayAd, pauseAd, linearAd) = await (overlay, pause, linear)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.