Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

shahab47

macrumors newbie
Original poster
Apr 8, 2012
13
0
Hello there.

I have 2 textfields in my very simple app.
When I run it in simulator and enter text in these two fields and then close the app (simulator is still running). And then open the app , I see that the text I entered earlier is still present.

How do I make sure that whenever my app is opened, the text field should be empty and it should not remember the contents present, the last time the app was opened.

Thanks
 
Look up UIApplicationDidBecomeActiveNotification, UIApplicationWillResignActiveNotification, and similar notifications. Your view controller should register for one or more of these notifications and return itself to whatever state you need when the app opens due to its icon being tapped.
 
it would be great if you can explain this with the help of an example..The documentation is overwhelming.
 
Does the viewWillAppear get triggered on that viewController when you come back from the background?
And what Phoney means in your appDelegate function (get back from background) -> UINotificationCenter, you can POST a NOTIFICATION, and in your viewController you can OBSERVE a NOTIFICATION.
That should give you enough keywords to move on.
 
Thanks a log jnoxx. However I am a beginner. Never worked with C or GUI.
Could you please explain with the help of an example ?
or just a line of code which explains your steps?

Thanks
 
Let me suggest that this is not the way to learn iOS development. Follow an online course like the Stanford lessons or get a book and read it cover to cover. If you ask a question but don't understand the answer then you need to start with the basics.

jnoxx, I really meant what I said. Register for one or both of those notifications. The app delegate has nothing to do with it.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.