Since the objective-c class without a constructor, the class is instantiated by the function to achieve, if such a function many words, it is not every function must initialize class
Member?
For example
@ Interface MainController: UIViewController
{
@ Private
bool a;
}
I now want to initialize a YES how to write ah?
Reply:
No constructor, ah, certainly inherited the parent class constructor, but not on a assignment to write a public function on their own private variable assignment. Do not know you?
Reply:
You can initialize a class in the viewDidLoad
Reply:
In the - (void) viewDidLoad in the relevant variables are initialized when the controller was time to load, it will automatically call viewDidLoad method, some classes, so you can write in the init, such as Class * class = [[Class alloc] init]; when When you create the Class class to allocate memory when it will call several methods init initWith ..
Reply:
The problem now is that the init method too much, ah, if you have 10 init, that I did not write 10 times.
Reply:
You can leave a bool a payment to be worth an interface
- (Void) setBoolValue: (bool) blValue
{
a = blValue;
}
Where used, the payment of the value of what can be ah
Reply:
You can write an init
Then the structure is similar to other functions such as research init initXXX
No comments:
Post a Comment