iOS How to use IBAction (Button Press) in ViewDidLoad/ViewWillAppear?

Terenc3

macrumors member
Original poster
Jul 15, 2010
35
0
Hi and thanks for reading. :D

I want to automate this part of my code:

Whenever a view loads, I will need to click a button (IBAction for Loading Data From NSUserDefaults) inorder for all saved data to be displayed.

However, I wish for this to happen without me clicking and all will appear automatically once view appears.

I reckon it will be good to use ViewDidLoad or ViewWillAppear (By putting an IBAction command in it). I am not entirely sure how to implement this.

Anybody can help me? :p
 
Last edited:

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Why have a button after all when it's automatic? ;o
You need to know what methods are, how to call them (which is actually really really easy basics of the development).
Just put your code from the button in a method, call that wherever you want it to be (the method), and you should be on your way, don't really see the issue here.
 

Terenc3

macrumors member
Original poster
Jul 15, 2010
35
0
Yea.. Thing is that, I had no programming background at all and my project are all meshes learnt from the web :p.. Hence, I really have no idea how :(. Meanwhile, I am still googling around though.. Thanks for your replies anyways! :D

P.S: How do I automate load function without the button then? :confused:
 

dejo

Moderator
Staff member
Sep 2, 2004
15,725
447
The Centennial State
Yea.. Thing is that, I had no programming background at all and my project are all meshes learnt from the web :p.. Hence, I really have no idea how :(. Meanwhile, I am still googling around though.. Thanks for your replies anyways! :D
In that case, I'm gonna suggest you step away from the real coding and spend some time learning the fundamentals of Objective-C / iOS programming. Knowing the basics is only going to help you in the long-run. Patching together code snippets from the internet is not a sound approach, IMHO, to developing a well-written application.
 

Doug-Baker

macrumors newbie
Mar 20, 2012
4
0
Check out Apple's iOS tutorials

Hi Terenc3,

I'm just getting going with iOS programming myself, and I've done what you have -- hunt the web, plus buy some books. In my case, I was trying to look for good Master - Detail / UINavigationController tutorials, and I kept coming up disappointed.

It was only after I went back and poked around developer.apple.com that I found the "Your Second iOS App: Storyboards," which dealt exactly with the UINavigationController and using Master-Detail views. And what I've found is that this Apple was much better than what I managed to find through Google or my books.

So my recommendation is to go to the Apple developer site and see what they have there.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
I suggest reading through some books, you don't need to be the best coder in the world all out of a sudden, but basics are nice, or you will keep hitting yourslef in the head alot afterwards.. Heck, every couple of months when I look at my code I feel the same like before, feel sad and have learned alot.

So just check out the basics and then head back for more questions :)