In swift3 I have done multiple segue's but in my latest one when I do one:
self.performSegue(withIdentifier: "registrationSettions", sender: self)
where registrationSettings is a "show" segue to my RegistrationViewController class.
In xcode 8 it just steps over the performSegue call without doing a transition into the view controller code (I have a break point in it in the viewDidLoad (first line) and it isn't reached). And no errors are generated to the system console.
I have over 15 other classes where doing segue's work just fine. So my question is under what cases can performSegue be used where the view controller isn't entered and no errors are generated in the system console? I know that the segue specified is correct because I have tried spelling it incorrectly and I get an error in the system console. I have also used a segue link to a view controller that works and the transition works fine.
I have deleted and re-added the view controller and deleted and re-added the structure for it in the Storybook and it still acts the same.
I can add the code but I don't know how I would show the Storybook structure. But it still comes back to why the performSegue call is stepped through in Xcode without transitioning into the view controller code and no errors are generated to the system window.
Has anyone seen this behavior? I have done several days of surfing and haven't found anyone who gets this behavior. Usually it results in errors in the system console.
Related
I am making the auth portion of the app (login,register,forgot password pages). since i have a function that handles the errors which i call for all the different transactions (log in, log out, register user, etc) and if it catches that error then it sets a custom message to a variable in my viewmodel(environmentObject) which then is observed by a view on the screen that draws it to the screen accordingly.
Problem is that if i get an error in login page and say navigate to forgot password then the error is still saved on that viewmodel variable and since it is also observed from forgot password page then it gets displayed on this page even though it has nothing to do with it. (this happens between all screens not just those two). The fix i have in mind is resetting the variable every time i navigate into a new page, however i have no clue how to do this swift. Using swiftUI
I have tried using init block and reset the variable there however init runs before my environmentObject is initialized therefore I cannot set a member variable there.
I ended up using .onAppear(perform:{ //reset variable here}) on the highest view of each screen and it worked like a charm, alternatively I could have use .onDisappear() on the oldScreen to produce a similar effect
I'm trying to find where to put app initialization code that should NOT be run in preview mode. I've seen several answers suggesting it's incorrect to split the app behaviour this way (launch vs preview), but I disagree: many apps need to do additional setup (eg connect to database, launch background tasks, call APIs, etc) that isn't appropriate for the preview (where static test data makes most sense).
In preview mode, Xcode actually runs the app and calls AppDelegate.applicationDidFinishLaunching, so any post-launch initialization code there will be triggered.
What is the recommended way to run app setup code so that it doesn't run in preview?
It appears that Xcode sets an environment variable when running the app for SwiftUI previews. The key is "XCODE_RUNNING_FOR_PREVIEWS", which will have a value of "1".
Given this I found putting a guard statement that checks that environment value in my applicationDidFinishLaunching implementation before the initialization I didn't want to occur for previews fixed my preview (my initialization was making them fail entirely).
I also wrapped it in a DEBUG check to ensure it would not ever accidentally break a production build.
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Initialization needed for previews
#if DEBUG
guard ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1" else {
return
}
#endif
// Further initialization not needed for previews
}
The Preview Live, I assume you mean it, creates complete window scene context and injects there view to be previewed, so all application & scene delegate methods are called including instantiating root ContentView, but the root view is not shown, ie. its body is not called.
Thus you can achieve your goal by placing code, initiating all heavy/network/etc. operations in root view's .onAppear callback. And this, actually, will be good for your users as well, because such approach gives fast application start and initial UI presented.
TL;DR:
Workaround this issue by putting your SwiftUI code in a framework and make it the selected scheme in Xcode before viewing your previews.
Details:
Looks like SwiftUI Previews need to build a target that contains the SwiftUI code (makes sense), but that target doesn't have to be an app! So it's unclear why it needs to run the app at all, but clearly it does. Xcode picks which target to build from the currently selected scheme (if you pick a target that doesn't build the required SwiftUI files, you'll get an error in the previews). So here's a workaround:
Add a new framework target
Put your view code in that new target
Select the scheme for that new target
Run your preview
This also has the advantage of only compiling the new target (and its dependencies) for rendering previews, which is likely to be faster that building the whole app.
Any dependencies will of course need to be accessible from that new target.
This works at least in Xcode 12.5.1
All,
I have searched around for an answer to this but have yet to find a good explanation and solution. Hopefully, you can help.
I have a route that renders an Ember.ContainerView (as opposed to a standard Ember.View). When I transition away from this route and then back to it (either via the back button, a link-helper or just changing the url) I get the following error in the console:
Uncaught Error: Assertion Failed: calling set on destroyed object
I understand that a high level reason for this is that when we transition away from the route with the ContainerView, it's childViews are marked as destroyed. When we transition back to the route, the problem has something to do with Ember trying to set the childViews back to the destroyed instances.
I'm not exactly clear but that is the vague understanding I currently have.
So, my questions are as follows:
Can you please correct my understanding of this problem if it is not correct?
Can you please tell me how to fix this error?
For your convenience, I have created a JSBin example for your viewing pleasure. To replicate the error, open your JS console, click on the Go to Route two link, then click on the Go to index link. Now check your logs.
Thanks in advance for any assistance you can provide.
Here is the fix: http://jsbin.com/jumoy/1/edit?html,css,js,output
I have encountered this problem before. I can't say I truly understand it at a very detailed level, but here is the general problem. When you are defining your container view, it is actually creating that subview when you define it, not when you create an instance of the view. This means that your childview 'initial' is only being created one time, and thats when the file is initialled parsed and the ContainerView is defined. When ember cleans this childview up, it is not gone for ever and 'initial' will always be equal to a cleaned up view.
By setting 'initial' as a property, it will be created every time a new instance of your container view is rendered, and therefore a new childview will be created and accessible.
So moral of the story, try not to create objects in definitions of controllers/views. Instead create properties that return the creation of that object.
Hope this helps and makes sense.
UPDATE::
I have edited the jsbin to show you on a deeper level what is happening and why it isn't working. To see the effect uncomment the second ContainerView and comment out the first, you will notice in the console logs that the second time you go to the twoRoute, it has marked that initial property as state: destroying for the view.
http://jsbin.com/jumoy/2/edit?html,js,output
if you are using Ember.Instrumentation namespace for publishing your events and Ember.subscribe to listen to them in your code, when you publish events, it stack all the subscribers and call them even when they are destroyed.
so basically, when for example your route is destroyed which is running subscribe statements it will fail and give above error.
Here is a solution to this problem: Use Ember.Instrumentation.reset() to remove previous subscribers which are destroyed. This solution helped me in acceptance tests where app was destroyed after tests are finished.
I wrote Ember.Instrumentation.reset() in startApp function of module-for-acceptance.js and it worked.
Hope that helps.
I downloaded iAd Banner Sample for cocos2d V3. Thanks so much for that code. The demo works fine and needs the user to tap Show Ad or Hide Ad button. Of course in my game I do not want the player to tap a button to Show Ads. In IntroScene.m I commented out the code that creates the buttons and added these lines at the end of init:
AppDelegate * app = (((AppDelegate*) [UIApplication sharedApplication].delegate));
[app ShowIAdBanner];
This is the same code that would have been executed if the Show Ad button had been pressed. I expected to see an ad without having to tap a button. However, I got no ad. I got the following error message in the log:
ADBannerView: Unhandled error (no delegate or delegate does not
implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain
Code=2 "The operation couldn’t be completed. Loading throttled"
There is -(void)bannerDidFail method in AppDelegate. It works by tapping button. How do I get the ads to show up automatically, without tapping a button first? Thanks.
The error seems to tell you exactly what is happening. Make sure that you have the following line:
bannerView.delegate = self; //bannerView is an object of type AdBannerView* that you created before
Check also that the class where the previous line is, implements the method:
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
I recently wrote a tutorial on integrating iAds in Cocos2d-x v3. Although the language is different (C++ instead of Objective-C), the procedure and syntax are rather similar: http://becomingindiedev.blogspot.com.es/2015/02/integrating-iad-in-cocos2d-x-v3x.html
I am working on a MFC Document View architecture application which has multiple documents and views and a tabbed window interface.
I have been tasked with making an automatic switch to another tab on the press of the OK button in one of the other tabs. When the other tab is clicked on it uses a C++ wrapper over IWebBrowser2 to navigate to a specific web page.
When this is done manually by clicking on the tab everything is fine and the webpage within the view loads successfully.
In my first attempt at doing this the tab successfully switched in response to a call to
AfxGetMainWnd()->SendMessageToDescendants(SOME_MESSAGE, ...);
however by sending this windows message at the wrong point the application would crash once control returned because the chain of events caused the (modeless) dialog (*) that
sent the message, to no longer exist.
I then found the correct place to make the call, but now when the other tab is activated, it no longer displays the webpage as it should.
To debug this problem I added code to check the READYSTATE in both the situation where it works and the situation where it does not. When the page fails to load (despite the call to Navigate2 returning S_OK), the READYSTATE just stays at READYSTATE_LOADING.
Unfortunately now I am to many edits away from when I had it partially working.
I have added TRACE statements to the most obvious events such as OnSetFocus, CView::OnActivateView but all traces come out in the same order despite the behaviour being different
* hosted in the view