Is there any problem with the usage of static variable in Objective-C? If yes, please explain.
Reason for usage of static variable
I have two classes
- MainView
- WifiConnection
When the application loads, I am in the MainView class and will call a method from the WifiConnection class(method name:send).send method to initialize instream and outstream which is declared in the WiFiConnection class.
So it will send data successfully the first time. But sending the second time I do not need to initialize instream and outstream which is already initialized.
But this time when I look instream and outstream value it will be null. So I declared these variables as static and solved the above problem.
And also, how do I declare a class type variable as global?