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

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -