Post

Replies

Boosts

Views

Activity

Confused with type erasure when working with existential type
As per the talk, we have the following example: protocol Animal {     associatedtype CommodityType: Food     func produce() -> CommodityType } protocol Food {} struct Farm {     var animals: [any Animal]     func produceCommodities() -> [any Food] {         let produce = animals.map { animal in             // animal has type Animal             animal.produce()         }         // produce has type [Food]         return produce     } } In the video(03:51) the lecturer goes on to explain that the type of animal is any Animal but when I wrote the same code I can clearly see that the type is Animal - thus what happened to the existential ? The same goes for the return type of produce - I was expecting the type of the value to be any Food but it is Food. Anyone can explain the reason for the mismatch between what is shown in the lecture and what the compiler shows ? Using Xcode 14.2
1
0
789
Mar ’23
Is there a change to the iOS 15 UIPasteboard API with regards to "Secure Paste" ?
In session 10085 of wwdc21 https://developer.apple.com/videos/play/wwdc2021/10085 as well as this article https://www.apple.com/newsroom/2021/06/apple-advances-its-privacy-leadership-with-ios-15-ipados-15-macos-monterey-and-watchos-8 we are being told about the new Secure Paste in iOS 15. From the newsroom article: "With secure paste, developers can let users paste from a different app without having access to what was copied until the user takes action to paste it into their app." I am struggling to understand how can a developer let users paste from a different app without having access to what was copied ? Currently by using the UIPasteboard API we can very easily obtain what was copied from another app - the only difference is that the clipboard warning banner now doesn't show when the user selects paste from the clipboard menu.
0
0
975
Sep ’21
Confused with type erasure when working with existential type
As per the talk, we have the following example: protocol Animal {     associatedtype CommodityType: Food     func produce() -> CommodityType } protocol Food {} struct Farm {     var animals: [any Animal]     func produceCommodities() -> [any Food] {         let produce = animals.map { animal in             // animal has type Animal             animal.produce()         }         // produce has type [Food]         return produce     } } In the video(03:51) the lecturer goes on to explain that the type of animal is any Animal but when I wrote the same code I can clearly see that the type is Animal - thus what happened to the existential ? The same goes for the return type of produce - I was expecting the type of the value to be any Food but it is Food. Anyone can explain the reason for the mismatch between what is shown in the lecture and what the compiler shows ? Using Xcode 14.2
Replies
1
Boosts
0
Views
789
Activity
Mar ’23
Is there a change to the iOS 15 UIPasteboard API with regards to "Secure Paste" ?
In session 10085 of wwdc21 https://developer.apple.com/videos/play/wwdc2021/10085 as well as this article https://www.apple.com/newsroom/2021/06/apple-advances-its-privacy-leadership-with-ios-15-ipados-15-macos-monterey-and-watchos-8 we are being told about the new Secure Paste in iOS 15. From the newsroom article: "With secure paste, developers can let users paste from a different app without having access to what was copied until the user takes action to paste it into their app." I am struggling to understand how can a developer let users paste from a different app without having access to what was copied ? Currently by using the UIPasteboard API we can very easily obtain what was copied from another app - the only difference is that the clipboard warning banner now doesn't show when the user selects paste from the clipboard menu.
Replies
0
Boosts
0
Views
975
Activity
Sep ’21