Swift 3 Reset all contents of the app - ios

Is there a way to reset all contents of the application when user goes back to the home screen? Basically while users are using my app, certain view controllers save items in a list but instead of deleting all these items individually, I want to be able to reset the data like as though the users started the applications fresh.
Please, any help would be greatly appreciated
Thanks!

Ok, there is no automatic way to reset all contents. You must detect application goes to background event and manually delete all data.

Related

How to detect which tab a user has opened?

I'm new to swift and started to program a simple application in xcode. The application has multiple tabs in which in the firs one the user enters some data and the data should show in another tab. However I'm not able to achieve this as I don't know how to update a screen with the new data. Any help would be appreciated.

TodayViewController recreated every time Notification Center is shown

When trying to develop a Today Extension for iOS 8 I found a weird issue. It would seem that the View Controller I'm using is being recreated every time the user opens Notification Center. This means that there is no data retention and hence no way for me to know if the extension needs to update or not.
The main reason for wanting to do this is that I want to preserve the height of the widget (Using preferredContentSize). The problem is that when the view loads this value always gets reset which leads to the widget jumping around in size. The Stocks widget is an example of how it's supposed to work and they've obviously solved it so there has to be some way of retaining the data between different "sessions". I can also tell from the debugger that the process continues to run, so it's just down to something in Apple's code forcing the View Controller to be recreated.
My question is, is this a bug? Or is it based on some setting or some property that I'm missing? Or is it maybe just the way it's supposed to work? If so, what is the workaround?
That's the way they work. Save your information to the device so you can reload it the next time you launch, along with the update time so you know if it's out of date. For small amounts of data, just use NSUserDefaults. For larger amounts save to a file, CoreData, sqlite, etc.

how to make a view appear only if is the first time? [duplicate]

This question already has answers here:
Show screen on first launch only in iOS
(8 answers)
Closed 9 years ago.
Thanks in advance .
I wanna make a view appear only if the application is launch for the first time, I have work with a similar code to display Alerts, but I can find a way to make it with a Storyboard view ? For example my idea is : in the image below I have 7 buttons so I want the user to select which Country/Button they wanna use after this first time launch (it will be a button where they can change it back ) and how can I save the value of the button (the one that the user choose) so that every time the app launches again it goes straight to the one they selected when the app was installed ?
Thank you .
There are two pretty easy solutions I can think of.
First, in both instances, you'll be duplicating much of the same logic you say you've used previously in displaying a UIAlertView.
Option 1: Have the view with buttons that should only be displayed once as the first view. In the viewDidLoad method, check whether the app has been launched before and a button has been selected. If a button has been selected before, just go ahead and perform the segue straight from the viewDidLoad into the rest of the app.
Option 2: This time, instead of starting with the 1-time view, start with the standard first view. Check if the app has been launched before or not, and if it has, perform a modal segue into the view where they select a button (otherwise just don't perform the segue).
I'm certain there's a more elegant solution to get this work in a better way, but this is a pretty simple implementation that should be quite easy to get working.
I would us an NSUserDefault here. First check for the presence of a preference for the key you specify. If it doesn't exist you'll want to show the region selection view. If it does exist just use the region stored in the preference.
This way, if the preference every gets deleted or lost, the logic will be small enough that the user can recover fairly quickly.

Make a To Do/Task Manager iOS App with UITableView, EditMode, and plist file?

I have to make an app for a camp that I'm attending. I want to make a task manager/to do list app. I want to have a tableview with the tasks. When you tap on a task, it will show a new page with the details of the task. You can add a new task with a description in two different text fields (one for each.) I want the entries to be saved to a plist file that would be read by the table view. I need a way to start edit mode to rearrange and delete the items from the TableView and the plist. When you touch the add button, I want a screen to come up with a UITextField and a UITextView. The text field would be for the task name and the text view for the details. Does anyone know any tutorials or code that could get me started? Any help is appreciated. Thanks.
You should check out this tutorial.
http://www.raywenderlich.com/21842/how-to-make-a-gesture-driven-to-do-list-app-part-13
It runs through how to make a persistent to-do list and will help you get your start.

creating an interactive page (videos, photos) for sharing on iOS device

I am building an iOS app, using storyboard. I have created a page where the user can create a page that will then be then published on DropBox and shared between all app users. this page lets you add photos, videos (not yet), and textviews (with scrolling enabled). Until know when the user presses the upload button, a screenshot is taken and uploaded, then views from a table view. but obviously it is just an image, so you can't scroll the textfields to see all the content and if I wanted to add the video support it would not be able to play it. I tried doing research on the internet, but I am a bit confused. Do I have to save all the components (UITextField...) separately, and place them in the same DropBox folder, and then put them all back together? What do you suggest? Is there a way?
Of course you will have to save the data separately...how else would your program know how to create the view? I recommend JSON or XML. Don't ask about how to structure it, that is a different question and one you should think about yourself.

Resources