How do I fix this? The recommended fix just causes more problems. I have code in another project where this exact same scenario works but when I'm applying it to this project I get an error I've never seen before. Am I missing something? Thanks
Figured it out it had something to do with the function buttonhit. Once I fixed it, it works now
Write the Image and both Text in VStack in the Navigation Link.
Related
Following part 3 of Apple's tutorial on SwiftUI, Handling User Input, I get this error:
Unable to infer complex closure return type; add explicit type to disambiguate
I'm using the same code as the tutorial (even coping from the 'Complete' sample code doesn't resolve the error).
Does anyone have a cue what is going wrong here?
struct LandmarkRow: View {
var landmark: Landmark
var body: some View {
HStack {
landmark.image(forSize: 50)
Text(verbatim: landmark.name)
Spacer()
if landmark.isFavorite {
Image(systemName: "star.fill")
.imageScale(.medium)
}
}
}
}
Regardless of the cause of the issue, how could you indeed add an explicit type to disambiguate here? What would the return type in such a case be?
--
Update
Apparently you should not continue with your result of the 2nd tutorial with the 3rd. Some things changed in between of the tutorials that is not documented in the tutorial. I've added the project files to Github so you can check out the diff.
It's better to start the 3rd tutorial fresh with a fresh download of the Project files of the 3rd tutorial.
The issue is not with the closure, but with the isFavorite property on landmark.
It is not declared on the Landmark type, and the compiler instead of showing the undeclared property error, unable to resolve the stacks build closure return type, so it shows and error there.
Great job Apple tutorial writers and even better one Xcode11 compiler.
To fix:
Declare isFavorite variable on the Landmark type.
Make sure you update the landmarkData.json for every landmark record with the isFavorite = false entry, otherwise the app will crash at runtime.
Some background to this problem
Like #dirtydanee already answered there is a difference between those two tutorials. But the problem behind the problem is that while it looks like you're doing a configuration it's actually just functions nested in functions using generics and protocols to "magically" parse everything into a compiling function.
However conformance to these generics and protocols need to be pretty precise because if not the whole tree of functions cannot compile anymore. But it's hard to determine for the compiler what conformance actually failed. This is why you see an error at the top rather than at the point where it actually happens.
It's strongly advised to make sure your views are decomposed into natural and simple blocks so you're not pouring over hundreds of lines of View code to find that one bug.
Dave DeLong had a really great talk about how to compose Views from ViewControllers that still holds true until today: basically you never use View as a subview inside another View but you need to decompose your View of many, simple Views. Otherwise these errors'll drive you nuts.
For people getting this error on SwiftUI and looking for a way to debug their view stack
This error happens mainly when there is a compilation issue on one child View.
1 - Make sure your parent view can support multiple subviews (VStack, ZStack) and you have less than 10 subviews. Sometime you may want to add a Group wrapper.
2 - If this is not the problem, there is probably an issue with one subview. Try to isolate the one you suspect to have the issue. Usually I copy the subview into a property and a different error appears
var debug: some View {
MyViewWithError(property: self.property)
}
Most of the time you'll encounter this because you pass the property (self.property) instead of a binding (self.$property)
Hope this can help some people
I have run into this error when made a typo. Also this error appears when a code has syntax issues. Just check if your changes are correct
I encountered the problem in a subview where a #Binding prop was of a different type of the #Binding source.
I have been trying to add a component within a view, I could do it but I am getting some warning message as well like "DEPRECATION: Using the defaultContainer is no longer supported". There is a related post here : emberjs append works but raises Assertion Failed error but not sure what I am doing wrong. Here is my jsbin link : http://jsbin.com/tuwanava/1/
Your help will be very much appreciated. Thanks.
Use
sticky.pushObject(App.ConfirmDeleteComponent.create());
Anyone have any ideas why I'm getting this error:
Uncaught TypeError: Cannot redefine property: __ember1346884664897
when calling:
App.get('router').send('tags')
I'm making the call from one of my views, the router is in the correct state, and as far as I can tell I'm doing everything by the book.
Would really appreciate any ideas...
Created a gist that might help explain things a little better. https://gist.github.com/3647288
App.router.send('something') will look for a function named something in your current state, but you are trying to use route name there. You should have something like showTags in you router and use App.router.send('showTags').
Head to docs http://docs.emberjs.com/#doc=Ember.Router&src=false and look at the part Transitions Between States
I had this problem when I named an action and a state the same way. Perhaps you have the same thing now.
Is there any way to create breakpoints in clojurescript?
Either in the repl or in chromes native debugger.
I've tried (js* "debugger") and this returns
SyntaxError: Unexpected token debugger
Thanks!
(js* "debugger;") should work. You're just missing the semicolon.
In case someone see this later,
If you are inside a go block you might need to use this: (js* "0; debugger") because go macros creates variables definitions everywhere, so that fix on that scenario.
If for some other reason it doesn't, check the error log, you must like can find a way to "hack" the invalid compilation by adding something.
The goal is to make users be more specific when reporting a bug.
Ususally I get a messy report "It doesn't work, please help ASAP!" from a user, so I keep asking the same questions each time -- "The why, the who-what-when, the where, and the how..."
Instead, I want to set a template for a new issue, something like this:
What page did you go? What login did you use?
What did you see?
What did you expect to see?
Why do you think this is a bug?
or whatever.
Is it possible?
This plugin would be very helpful, in your case,
Issue Templates- http://www.redmine.org/plugins/issue_templates
here is a patch for templating issue descriptions. anything beyond that is still underway, and is relevant to the issue mentioned above.
http://www.redmine.org/issues/2931
The link below says that you can for the last year or so:
http://www.redmine.org/issues/1138
But I haven't yet found a description of how this functionality is used. I guess I'll have to slog through some code to find out.
Maybe a possible workaround is to have an issue to use as a template.
Create an issue like this:
name: Bug template
description:
What page did you go?
What login did you use?
What did you see?
What did you expect to see?
Why do you think this is a bug?
Then you can duplicate it each time you need a real issue.
The limit is with issues with subtasks. If you duplicate the parent issue you don't get the subtasks duplicated as well.