I am new to Parse and iOS app development, so please pardon my question if the answer is obvious.
Does a function execution continue if the next view in a view hierarchy (nav controller) is loaded?
I currently have a view where the user takes a picture, which is then displayed on screen. I want to begin the upload and packaging of this image immediately, to save time. So my question really deals with the [saveInBackground] and [getObjectInBackground] functions. If the user taps the button to go to the next view, before the upload is completed, will the functions stop their execution or continue until it completes?
Thanks
Siddharth
As long as you use the function saveInBackground, your photo will be saved even if switching views. If you used saveEventually then the photo would be saved whenever it can (if there is no internet it will upload it when internet becomes available).
Related
I am a newbie in iOS development/firebase.
I have two view controller,
the first one does nothing expect performing a segue to the second view-controller
The second the view controller I have two buttons,the firstone is (back) which dismiss a view controller and the second button(up) have the following code
Database.database().child(“posts”).setValue(1)
1- If I have an extremely bad internet connection, and I pressed on up button then immediately pressed on back,
Does the code for uploading data for firebase stop on continue?
2- After pressing up, I immediately go to background and dismiss the app, will it continue setting the data?
All database operations are handled on another thread that's not related to any UI elements in your app. As long as your app is running, database operations will continue until complete.
If the app is no longer running, database operations will stop. If database persistence is not enabled, all of that pending work will never complete. If database persistence is enabled, then the SDK will try again to synchronize the writes that didn't complete previously.
I have a tabbed iOS application with each of the tabs having some sort of json request so the view loads ever so slightly slowly. I want to remove that lag completely so I'm wondering if there is a way to call the ViewDidLoad function from each of the classes during the login phase of the application.
if (login == "Success") {
UserDefaults.standard.set(true, forKey: "isUserLoggedIn");
UserDefaults.standard.synchronize();
DispatchQueue.main.async {
// Load all resources here
}
}
I can understand this can be bad practice if the app is very large, but I think in this scenario the app isn't huge, but the lag between the view controllers is enough to be annoying. I would rather have the user wait at the start for 3-5 seconds whilst everything loads, and have a smooth experience once inside. Is there a way to do this?
You shouldn't call the lifecycle functions of the viewcontroller for yourself. The viewDidLoad function will be called when the view has been loaded.
Apple: This method is called after the view controller has loaded its view hierarchy into memory.
So calling let _ = viewController.view will trigger the view creation and the call of this function.
But i think it's much better to have a startup phase instead. Think about a 'startup'-screen that downloads everything you need (with maybe a spinner and a text) and moves automatically to the content (the tabbar controller) when done. That may also fix the problem of a low network connectivity (think about a download that take a minute for example). You may display that screen modally above or as screen before the tabbbar controller.
If you don't like the idea of a startup phase you may also design your ui responsive. Start the download whenever needed / regularly and update your ui according to the results when ready. The ui will be fast then, but uses last known data. The meaningfulness and implementation depends on your content.
Update
On second thought: If you already have a server login screen, why not download the content directly after the successful download as part of the login? Users do not know if you are still checking the login or downloading some necessary data. You may say that login is only successful if server login AND download are finished successfully.
I need my app to provide users to click multiple pictures. I want a layout with two separate buttons, one for clicking picture and another for saving the picture taken in the document's directory of filesystem. This screen will be presented and UIImagePickerController will be opened.
When user clicks first button, we will disable this button and show the picture obtained in an overlay. And show another button(this will be enabled now) to save this picture.
When user clicks another button, we will disable this button and save it in filesystem. After saving successfully, we will again enable the first button to take more pictures.
I have tried and implemented this app and it works perfectly at our end. But our some users report of app crashing when UIImagePickerOriginalImage key returned is nil.
This doesn't even happen to them frequently. Instead they face this crash after a long usage of app. However, we have tried of taking more 200 pictures and saving too. It didn't lead to any crash.
Please anyone suggest what might be the cause for this crash. Or any other better workaround to implement this functionality.
According to Apple documentation, "To help your widget look up to date, the system occasionally captures snapshots of your widget’s view. When the widget becomes visible again, the most recent snapshot is displayed until the system replaces it with a live version of the view."
What I am seeing, however, is that the snapshot is removed from screen before the live view is prepared. This results in a flash effect where the old snapshot is taken off screen, the view is blank for a split second, then the new view appears.
Is the developer responsible for making the transition between the snapshot and the live view seamless? If so, what is the strategy behind doing that? I don't see any way to directly control that transition.
I was able to mitigate the effect greatly by moving data loading to
widgetPerformUpdateWithCompletionHandler: and keeping drawing in viewWillAppear:, but I do still see a flash once every 15 (or so) opens of the Notification Center.
I had this same issue and finally figured out the issue I was having with my widget. It turns out it was related to a misunderstanding about the Widget Life Cycle on my behalf.
From the documentation I thought that the today view would keep a 'snapshot' of my widgets state until the widgetPerformUpdateWithCompletionHandler method completion handler was called with success.
This does not seem to be the case. From what I can see the 'snapshot' is just used when the Today View is animating in (when the user pulls down the notification centre). As soon as the today view is loaded and stationary your widget is loaded from scratch (inflated from xib if using) and viewDidLoad is called. At this moment you should populate you widget with cached data (not from a web request). If you don't you will see temporary data from your nib. This is what causes the flashing.
When viewDidLoad is complete widgetPerformUpdateWithCompletionHandler is called which allows you to fetch fresh data. When the fresh data is fetched you should call the completion handler and cache the data it so it can be used when the widget is loaded later on from scratch (in viewDidLoad).
A simple way to cache the data is in user defaults.
You need to be careful about your compilation handler in the
-(void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler
method. What happens is that your extension probably has an error and everytime view appers it is being called again. Try to attach your extension to debugger(Debugger->Attach to Process-> your extension id) and see the result by putting some breakpoints.
every one knows that skstoreproductviewcontroller's loadproductwithparamters method need to ask app informations from web,so it load very slow,is there any method to run loadproductwithparameters in background to show the app information fast?
The information will naturally load in the background and the intention is that you call loadProductWithParameters:completionBlock: before you actually want to display the view (and you can use the completion block to either show the view or to tag the item as being available to show).