objective c - custom class = custom +alloc , custom +init -


I am new to the purpose for the iPhone.

I am writing a custom class, so, should I write my + alloc, + init methods? I believe that: + alloc will just call [thing alloc]; And + init will do something like this: [chess set value: X];

Is there a "default" + allocation and + init methods? If so, what should I wait for the default + alloc and + init? Suppose I have NSMutableDictionary * i.e.

  @interface class1: NSObject {NSString * test; NSMutableDictionary * Maps; }  

thanks

You do not usually have to type Your own + alloc method

For your example, you may have a one -init that looks like this:

  - (id) init {self = [super init]; If (self) {map = [[NSMutableDictionary dictionary] is maintained); } Healthy return; }  

Note that you call superclass -init first, and before starting your own variable, check that it works.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -