Home > Blockchain >  Where is Self._printChanges() defined and/or documented for SwiftUI?
Where is Self._printChanges() defined and/or documented for SwiftUI?

Time:11-08

I have seen a few articles or video's on iOS 15's new Self._printChanges() function, but can not find any documentation on it anywhere. Does anyone know where Apple documented this new function? It is pretty obvious how to use it, but I would like to see what more we can do with it and knowing more about it would be helpful. Even Xcode's lookup's yield nothing. Anyone find anything?

CodePudding user response:

Unfortunately, _printChanges() is a private API, which is why it's undocumented. The only reason so many videos and articles referenced it is because an Apple engineer mentioned it during WWDC21. Here's what they said:

It's not technically API-notice the leading underscore — so should only be used in debugging. My one sentence pro-tip is the extent of the docs I'm afraid.

Screenshot of chat room

However, Xcode does show a summary when you Option Click.

Summary
When called within an invocation of body of a view of this type, prints the names of the changed dynamic properties that caused the result of body to need to be refreshed. As well as the physical property names, “@self” is used to mark that the view value itself has changed, and “@identity” to mark that the identity of the view has changed (i.e. that the persistent data associated with the view has been recycled for a new instance of the same type).

  • Related