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?
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.
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
This is a very noob question. I'm proficient in css, but swift is new to me and so I am trying to think object based, but it's not natural yet. I have tried to understand MVVM which I think is core to the problem but I'm not sure so asking for help.
I want to create an app which has an 'index' central nav type view which I have put in contentview. Depending on what button is pressed I want it to invoke series of functionality but there are up to 9 different types of function that are entirely independent of each other. In html / css, I'd have a central nav index and 'link' to other function specific capabilities.
I don't want to repeat code, so I am trying to work out how to create an architecture that supports it. Where I am getting stuck is in the scoping of it as it is telling me 'this variable isn't in scope'. Fine. I understand the concept but not how to do it right. And I've watched hundreds of hours of video and still not found anything. As an illustration, say the contentview was main actor, and it was a navigator for topics on cats, dogs, lizards, snakes, horses, and pigs.
My thinking is that I'd keep contentview as the nav, and have separate swift files cat.swift, dogs.swift, lizards.swift etc and include them into contentview so their content was globally available. In each of those files I'd have the let catName = etc and much more content specific to that function area. But then from within cat.swift I'd also want to include dog.swift, horse.swift etc as well so the user can navigate those too. In css I'd do this via links - which is probably utter idiocy in swift.
So how do I do this in swiftUI? I don't in detail know the detailed differences between #stateObject, and #state and private var versus var etc and have tried to find a guide that says 'if you want 'catModel' to be available throughout the app define it anywhere with #makeitavailableeverywhere catModel and just trigger it into the view you want by '#include catModel'.
Not sure if this makes sense, but if someone can point me to where I can get accessible, translation into how to do this I'd be so grateful. The app is nearly complete - and I'm pleased, I just can't get the different .swifts to be in scope to each other.
Thank you!
In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".
This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.
How is this done? Is it something that's provided in the UIKit or available somewhere else?
Many thanks,
Michael
Venmo just open sourced their token field.
https://github.com/venmo/VENTokenField.git
edited:
The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.
Since iOS 13 there exists UISearchTextField.
https://developer.apple.com/documentation/uikit/uisearchtextfield
You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.
But be aware: You can‘t mix text and tokens at various positions.
From the docs:
Tokens always occur contiguously before any text in the search field.
Adding this here for reference:
Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.
I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement
I have a table (UITableView) and shall implement therefore the functions like in the iphone email-interface. This means: In the header right up I need a edit-button. When pressed, some cells can be marked and in the footer there appear several buttons.
Is there a library, where I can take the functionality from? If not, any idea, how I can Implement the "marking function"?
There's a cool example among the apple docs, which I guess meets well your request. Inspect it, I think you'll find much useful there:
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008913
I read this
"
It used to be that Android would use a single pass to process
RelativeLayout-defined rules. That meant you could not reference a widget
(e.g., via android:layout_above) until it had been declared in the XML. This
made defining some layouts a bit complicated. Starting in Android 1.6,
Android uses two passes to process the rules, so you can now safely have
forward references to as-yet-undefined widgets.
"
I do not know what is the problem maybe is eclipse problem, but even I use 2.3 I still have problems when I reference some view that is not declared jet so for me it seems like android doesn't uses two passes to process the rules for relative layout.
note: I always use #+id/widget_name when I declare the widget and #id/widget_name when I reference that widget from other widget. I have noticed that I can use #+id/widget_name even when I just want to reference that widget. I guess that is wrong but why sometimes is works without any complaints ? In my opinion one widget should be allowed to be declared only ones...
My questions is is really android uses two passes ? and I need some guidelines (best practices) for working with relative layouts
I am little confused about how this relative layout parings are made, so any explanations are welcomed
Thanks
#+id/name creates a new id, if it doesn't already exist. #id/name references an existing id, and will never create one.
I'm not sure if you can use #id/name before #+id/name in the same file. If not, I can think of two workarounds:
Always use #+id/name.
Define all id's in the ids.xml file, and always use #id/name.
This is general information on how Android draw views.
I think that Android passes twice through all the view, but it doesn't pass through each single view once. So if you have a reference from one xml to another it will always work fine, but if you have references inside a single xml you must be carefull to order the elements in the xml correctly. For example, I have view1 and view2 in my RelativeLayout. If I want to refer to view2 from view1 I must declare view2 before view1.
While searching a bug in my code today I found a strange thing. When inspecting a UIView instance in the debugger the variable view of Xcode does not show the subviews member of the UIView class.
I only see this fields in the debugger (> should indicate the opening triangle):
UIResponder
_layer
_tabInfo
_gestureInfo
_touchData
_charge
_tag
_viewFlags
I'm missing the _subviews member and come to think of it also all the positional members (at least one of them should be there).
Does anybody know what I'm missing or doing wrong (as far as I can tell it is not a problem as a google search for this problem didn't got me any results).
I use Xcode version 3.1.3 with:
XcodeIDE: 1191.0
XcodeCore: 1192.0
XcodeSupport: 1186.0
on a mac with OS 10.5.7 and iPhone SDK 2.2.1 (I also tested with iPhone SDK 3.0).
I hope somebody knows anything about this. It gives me a little strange feeling that I cannot trust the debugger to show me everything I should know for debugging a problem. And it's not good if you need to mistrust you tools :(
The debugger is only going to be able to show you members, not properties. Remember that the two are different in Objective C. A property is just syntactic sugar for a setter and/or a getter. So the read-only "subviews" property of UIView only guarantees that it has an implementation for this method:
- (NSArray *)subviews;
As you've noticed, Apple has implemented many of their properties using undocumented member variables that resemble their corresponding property names, but with leading underscores. This allows you to spy on the internals of some objects to see what's going on in some cases, but many properties aren't implemented in such a transparent manner. In these cases, you'll need to inject some diagnostic code into your app to access the property and output its return value using NSLog, and/or store the value in a temporary variable that you can observe in your debugger.
Don't blame the poor debugger. It's doing exactly what it's designed to do. If it helps, you can blame properties for trying to trick us into thinking they're member variables when they're really methods.