|Jul 28, 2012, 03:54 AM||#1|
Can you please explain the code below?
-(id)initWithName:(NSString *)newName atFrequency:(double)newFrequency;
Last edited by OllyW; Jul 28, 2012 at 11:54 AM. Reason: Please use code tags
|Jul 28, 2012, 03:17 PM||#3|
This indicates an instance or object method. This means you call this method on an instance of this class. The other option is a + which you call on the class itself. This is used for utility methods, object factories, etc.
This indicates the return type, which is id in this case. id is the most generic object pointer. It can point to any sort of object.
This is part of the method name. Objective-C methods have "segmented" names with arguments interspersed so each argument has a label, making it easier to know what the argument does, rather than just its type.
This indicates the type of the first argument. NSString is the Cocoa string implementation. The * indicates that the type is a pointer to an NSString. You will see this for every object type, as Objective-C dynamically allocates all objects on the heap, so you never have a "local" object used without a pointer.
This is the name of the first argument, and what will be used in the method to refer to it.
This is the second segment of the method name, the type of the second argument (double is a double precision floating point value. It is a primitive type.), and the name of the second argument.
|Thread Tools||Search this Thread|
All times are GMT -5. The time now is 11:18 PM.