[Solved] Understanding a method from objective-c [closed]


In this method a is the parameter of class StockHolding. So when passing parameter to the method, always * symbol followed by class. So that it will typecast to the object accordingly. For example below:-

This is the NSString class method:-

+ (id)stringWithString:(NSString *)aString

In this aString is the parameter whose type refers to NSString class. so if we call this method we can directly pass the string object without typecasting for example below:-

NSString *str=[NSString stringWithString:@"yourString"];

The advantage is that without doing type casting we can pass string to the parameter of the method.
Also if (!stockHolding) is just checking nil it means, if object is no longer exist then just allocating the same.

solved Understanding a method from objective-c [closed]