diff --git a/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json b/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json index 0186e2c4e..19f217d91 100644 --- a/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json +++ b/src/assets/json/en/ios/wwdc/ios-wwdc-listnota11y.json @@ -10,6 +10,17 @@ "raccourcis": "", "profils": ["All","Accessibility","Dark Mode","Debugging","DocC","Formatting","Instruments","Keyboard","Keynote","Localization","Optimization","Platforms State...","Regex","Shortcuts","Swift","Swift Playgrounds","SwiftUI","What's new in...","Xcode"] }, + { + "themes": "WWDC 2023", + "title": "Generalize APIs with parameter packs", + "type": [], + "tests": [], + "verifier": [], + "resultat": [], + "exception": "", + "raccourcis": "2023/2310168", + "profils": ["All","Swift"] + }, { "themes": "WWDC 2023", "title": "Keynote", diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_1.png b/src/en/mobile/images/iOSdev/wwdc23-10168_1.png new file mode 100644 index 000000000..3d54ba0da Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_1.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_2.png b/src/en/mobile/images/iOSdev/wwdc23-10168_2.png new file mode 100644 index 000000000..4c71afe6d Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_2.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_3.png b/src/en/mobile/images/iOSdev/wwdc23-10168_3.png new file mode 100644 index 000000000..f5eeabc2c Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_3.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_4.png b/src/en/mobile/images/iOSdev/wwdc23-10168_4.png new file mode 100644 index 000000000..6a77c24d1 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_4.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_5.png b/src/en/mobile/images/iOSdev/wwdc23-10168_5.png new file mode 100644 index 000000000..bf1349758 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_5.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_6.png b/src/en/mobile/images/iOSdev/wwdc23-10168_6.png new file mode 100644 index 000000000..c5cdf3050 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_6.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_7.png b/src/en/mobile/images/iOSdev/wwdc23-10168_7.png new file mode 100644 index 000000000..73fdfa562 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_7.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_8.png b/src/en/mobile/images/iOSdev/wwdc23-10168_8.png new file mode 100644 index 000000000..8ffee0006 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_8.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_9.png b/src/en/mobile/images/iOSdev/wwdc23-10168_9.png new file mode 100644 index 000000000..dd79f5fc5 Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_9.png differ diff --git a/src/en/mobile/images/iOSdev/wwdc23-10168_Poster.png b/src/en/mobile/images/iOSdev/wwdc23-10168_Poster.png new file mode 100644 index 000000000..ab203d2ae Binary files /dev/null and b/src/en/mobile/images/iOSdev/wwdc23-10168_Poster.png differ diff --git a/src/en/mobile/ios/wwdc/nota11y/2023/2310168.md b/src/en/mobile/ios/wwdc/nota11y/2023/2310168.md new file mode 100644 index 000000000..9214854a6 --- /dev/null +++ b/src/en/mobile/ios/wwdc/nota11y/2023/2310168.md @@ -0,0 +1,55 @@ +--- +title : "Generalize APIs with parameter packs" +abstract: "Abstract over types as well as the number of arguments in generic code." + +displayToc: true +--- + +# WWDC 2023: Generalize APIs with parameter packs +Find hereafter a detailed summary of a video that belongs to a [taxonomy of some WWDC footages](../../). + +The original video is available on the **Apple official website** ([session 10168](https://developer.apple.com/videos/play/wwdc2023/10168/)). +![](../../../../../images/iOSdev/wwdc23-10168_Poster.png) +"Swift parameter packs are a powerful tool to expand what is possible in your generic code while also enabling you to simplify common generic patterns. We'll show you how to **abstract over types as well as the number of arguments in generic code** and simplify common generic patterns to avoid overloads." +
Hereafter, the underlined elements lead directly to the playback of the WWDC video at the appropriate moment. +
+ +## [The origins](https://developer.apple.com/videos/play/wwdc2023/10168/?time=51) +![](../../../../../images/iOSdev/wwdc23-10168_1.png) + +Regarding a [client server example](https://developer.apple.com/videos/play/wwdc2023/10168/?time=124), the number of query arguments may be too large according to the needs. + +![](../../../../../images/iOSdev/wwdc23-10168_2.png) + +However, this problem might be partially solved while using the [variadic parameters](https://developer.apple.com/videos/play/wwdc2023/10168?time=136) combined with the [type erasure](https://developer.apple.com/videos/play/wwdc2023/10168?time=172) notion that give rise to some [limitations](https://developer.apple.com/videos/play/wwdc2023/10168?time=154) though. + +![](../../../../../images/iOSdev/wwdc23-10168_3.png) +This kind of situation is typically what **[parameter packs](https://developer.apple.com/videos/play/wwdc2023/10168?time=237)** are for. +
+ +## [The fundamentals](https://developer.apple.com/videos/play/wwdc2023/10168/?time=248) + +'A **parameter pack** can hold any quantity of types or values and pack them together to pass them as an argument to a function.' +![](../../../../../images/iOSdev/wwdc23-10168_4.png) + +Handling packs at the **type-level** is a [major difference](https://developer.apple.com/videos/play/wwdc2023/10168/?time=358) with the usual collections thanks to new ways for [writing code](https://developer.apple.com/videos/play/wwdc2023/10168/?time=376). + +![](../../../../../images/iOSdev/wwdc23-10168_5.png) + +It comes in handy to [avoid boilerplate code](https://developer.apple.com/videos/play/wwdc2023/10168/?time=513) in such situations... +![](../../../../../images/iOSdev/wwdc23-10168_6.png) + +...while easily tailoring the [generic requirements](https://developer.apple.com/videos/play/wwdc2023/10168/?time=655) on packs as well. +![](../../../../../images/iOSdev/wwdc23-10168_7.png) +
+ +## [Implementation](https://developer.apple.com/videos/play/wwdc2023/10168/?time=732) +It's recommended the **parentheses be used** for wrapping the pattern expression when the results are embedded in a tuple. + +![](../../../../../images/iOSdev/wwdc23-10168_8.png) + +Regarding the [initial example](#the-origins), if the **[input and output types need to be different](https://developer.apple.com/videos/play/wwdc2023/10168/?time=871)**, the code writing may be changed to tailor the parameter pack concept while improving the [flow control](https://developer.apple.com/videos/play/wwdc2023/10168/?time=1013) with the `do-catch` statement for **handling errors**. + +![](../../../../../images/iOSdev/wwdc23-10168_9.png) + +
\ No newline at end of file diff --git a/src/en/mobile/ios/wwdc/nota11y/index.md b/src/en/mobile/ios/wwdc/nota11y/index.md index 6178da80a..142cadce6 100644 --- a/src/en/mobile/ios/wwdc/nota11y/index.md +++ b/src/en/mobile/ios/wwdc/nota11y/index.md @@ -24,6 +24,7 @@ The videos that may be of interest to **designers** are highlighted with a **ded