Im really new to iOS Programming. Although I read lots of books and material I cant really find out an answer to a simple question.
I know C++ language, and I understand how variables are handled through the functions. What I really dont understand in iOS programming is how this thing is done.
For example, in C++ I create a class instance in the main function. When I call another function and I want to share this class instance all you need to do is:
myFunction(&myClassInstance);
When I switch views in iOS programming (and therefore classes) I dont know how to send a class instance that was created before. For example, if I am on the firstView of my program, and I switch to the secondView, how can I send the variables that I was currently using?
If I need to create an instance of a class that is going to be used though ALL the program, where I should create it? In C++ I would create it in the main function, in iOS Programming, where should I create it?
Thanks!
First of all what I understand from your question is
“In C++ when we have to pass instance of some other class we use reference argument. What is option in Objective C?”
So, Objective C is build up on C. So you can pass instance using pointer. like…
Other question is
“If I need some instance in all the program then where should I create?”
You can use AppDelegate class to hold that instance. Because instance of AppDelegate it accessible from all your program.
And you can create instance in “didFinishLaunchingWithOption”