EDIT: My bad, i found this thread while looking on a way to list all categories / construct single category without displaying picker first. Looking at the API it seems this is not possible, but as per my original post, the video suggests that it should be possible.
@Kmart are you sure? WWDC's "what's new in screentime api" suggest that it might somehow be possible.
https://developer.apple.com/videos/play/wwdc2022/110336/ at 5:25 you can see the following code snipet:
import ManagedSettings
extension ManagedSettingsStore .Name {
static let gaming = Self( "gaming" )
}
func worklogSetup() {
let gamingCategory = ActivityCategoryToken(...)
let gamingStore = ManagedSettingsStore(named: .gaming)
gamingStore.shield.webDomainCategories = .specific([gamingCategory])
}
Have no idea how that ActivityCategoryToken is constructed, but I don't think the code suggests that the user had to select that category beforehand. Later in the video they create another ManagedSettingsStore the same way.
Post
Replies
Boosts
Views
Activity
So it turns out it was my iOS 16.1 device that was failing to render shield properly. 16.4 simulator worked fine and as soon as I updated my device to now latest 16.6 it immediatelly started working.
Is there any chance you could share example project? I have no idea why, but my shield configuration extension code never gets executed. I've seen others struggle with the same issue as well.
I have related question - were you able to get the "tile" view in logic pro for ipad to render? That's the view in effect strip, before expanding it? For some reason i only get the blank square for my auv3 plugin.
This is super old thread, but since I found it while searching for the answer, I will answer it.
From the docs about init(layer: Any):
This initializer is used by CoreAnimation to create shadow copies of
layers, e.g. for use as presentation layers. Subclasses can override
this method to copy their instance variables into the presentation
layer (subclasses should call the superclass afterwards). Calling this
method in any other situation will result in undefined behavior.
So basically that method gets called when CoreAnimation decides that it needs a new copy of your layer. Changing background color triggers this. On iOS this method got triggered when I change strokeColor. If you have some custom vars on your subclass, you need to copy the values in this method (the layer argument is your old layer so you need to typecast it and then copy the custom params before calling super).