From what I could figure out just by playing around, the following rules are used to convert factory methods into convenient initializers.
- List item
- Method - a class method
- Return type
instancetype or MyClassName * - The method takes at least one argument.
- The method name begins with a "class name suffix"; that is, a class name suffix, with the restriction that you cannot have partial words. The first letter may optionally be lowercase.
The class name suffix (optionally followed by āCā, as in the initWith transformation) is deleted, and the rest of the method name is used for the first parameter, with the first letter lowercase.
For example, the following conversions apply:
[MyClassName myClassNameWithObject:obj] ā MyClassName(object: obj) [MyClassname classNameWithObject:obj] ā MyClassName(object: obj) [MyClassName nameObject:obj] ā MyClassName(object: obj)
Note: since they all map to the same fast initializer, only one will be available (usually the first one declared)
Jayson
source share