|
14 | 14 | @interface ASLayoutSpec : NSObject <ASLayoutable> |
15 | 15 |
|
16 | 16 | /** |
17 | | - Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a |
18 | | - layout spec can be created and mutated. Once it is passed back to ASDK, the isMutable flag will be |
19 | | - set to NO and any further mutations will cause an assert. |
| 17 | + * Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a |
| 18 | + * layout spec can be created and mutated. Once it is passed back to ASDK, the isMutable flag will be |
| 19 | + * set to NO and any further mutations will cause an assert. |
20 | 20 | */ |
21 | 21 | @property (nonatomic, assign) BOOL isMutable; |
22 | 22 |
|
23 | 23 | - (instancetype)init; |
24 | 24 |
|
25 | 25 | /** |
26 | | - * Set child methods |
| 26 | + * Adds a child to this layout spec using a default identifier. |
27 | 27 | * |
28 | | - * Every ASLayoutSpec must act on at least one child. The ASLayoutSpec base class takes the |
29 | | - * reponsibility of holding on to the spec children. For a layout spec like ASInsetLayoutSpec that |
30 | | - * only requires a single child, the child can be added by calling setChild:. |
| 28 | + * @param child A child to be added. |
31 | 29 | * |
32 | | - * For layout specs that require a known number of children (ASBackgroundLayoutSpec, for example) |
33 | | - * a subclass should use the setChild to set the "primary" child. It can then use setChild:forIdentifier: |
34 | | - * to set any other required children. Ideally a subclass would hide this from the user, and use the |
35 | | - * setChildWithIdentifier: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild |
36 | | - * property that behind the scenes is calling setChild:forIdentifier:. |
| 30 | + * @discussion Every ASLayoutSpec must act on at least one child. The ASLayoutSpec base class takes the |
| 31 | + * reponsibility of holding on to the spec children. Some layout specs, like ASInsetLayoutSpec, |
| 32 | + * only require a single child. |
37 | 33 | * |
38 | | - * Finally, a layout spec like ASStackLayoutSpec can take an unknown number of children. In this case, |
39 | | - * the setChildren: method should be used. For good measure, in these layout specs it probably makes |
40 | | - * sense to define setChild: to do something appropriate or to assert. |
| 34 | + * For layout specs that require a known number of children (ASBackgroundLayoutSpec, for example) |
| 35 | + * a subclass should use this method to set the "primary" child. It can then use setChild:forIdentifier: |
| 36 | + * to set any other required children. Ideally a subclass would hide this from the user, and use the |
| 37 | + * setChild:forIdentifier: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild |
| 38 | + * property that behind the scenes is calling setChild:forIdentifier:. |
41 | 39 | */ |
42 | 40 | - (void)setChild:(id<ASLayoutable>)child; |
| 41 | + |
| 42 | +/** |
| 43 | + * Adds a child with the given identifier to this layout spec. |
| 44 | + * |
| 45 | + * @param child A child to be added. |
| 46 | + * |
| 47 | + * @param identifier An identifier associated with the child. |
| 48 | + * |
| 49 | + * @discussion Every ASLayoutSpec must act on at least one child. The ASLayoutSpec base class takes the |
| 50 | + * reponsibility of holding on to the spec children. Some layout specs, like ASInsetLayoutSpec, |
| 51 | + * only require a single child. |
| 52 | + * |
| 53 | + * For layout specs that require a known number of children (ASBackgroundLayoutSpec, for example) |
| 54 | + * a subclass should use the setChild method to set the "primary" child. It can then use this method |
| 55 | + * to set any other required children. Ideally a subclass would hide this from the user, and use the |
| 56 | + * setChild:forIdentifier: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild |
| 57 | + * property that behind the scenes is calling setChild:forIdentifier:. |
| 58 | + */ |
43 | 59 | - (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier; |
44 | | -- (void)setChildren:(NSArray *)children; |
45 | 60 |
|
46 | 61 | /** |
47 | | - * Get child methods |
| 62 | + * Adds childen to this layout spec. |
48 | 63 | * |
49 | | - * There is a corresponding "getChild" method for the above "setChild" methods. If a subclass |
50 | | - * has extra layoutable children, it is recommended to make a corresponding get method for that |
51 | | - * child. For example, the ASBackgroundLayoutSpec responds to backgroundChild. |
| 64 | + * @param children An array of ASLayoutable children to be added. |
| 65 | + * |
| 66 | + * @discussion Every ASLayoutSpec must act on at least one child. The ASLayoutSpec base class takes the |
| 67 | + * reponsibility of holding on to the spec children. Some layout specs, like ASStackLayoutSpec, |
| 68 | + * can take an unknown number of children. In this case, the this method should be used. |
| 69 | + * For good measure, in these layout specs it probably makes sense to define |
| 70 | + * setChild: and setChild:forIdentifier: methods to do something appropriate or to assert. |
| 71 | + */ |
| 72 | +- (void)setChildren:(NSArray *)children; |
| 73 | + |
| 74 | +/** |
| 75 | + * Get child methods |
52 | 76 | * |
53 | | - * If a get method is called on a spec that doesn't make sense, then the standard is to assert. |
54 | | - * For example, calling children on an ASInsetLayoutSpec will assert. |
| 77 | + * There is a corresponding "getChild" method for the above "setChild" methods. If a subclass |
| 78 | + * has extra layoutable children, it is recommended to make a corresponding get method for that |
| 79 | + * child. For example, the ASBackgroundLayoutSpec responds to backgroundChild. |
| 80 | + * |
| 81 | + * If a get method is called on a spec that doesn't make sense, then the standard is to assert. |
| 82 | + * For example, calling children on an ASInsetLayoutSpec will assert. |
55 | 83 | */ |
| 84 | + |
| 85 | +/** Returns the child added to this layout spec using the default identifier. */ |
56 | 86 | - (id<ASLayoutable>)child; |
| 87 | + |
| 88 | +/** |
| 89 | + * Returns the child added to this layout spec using the given identifier. |
| 90 | + * |
| 91 | + * @param identifier An identifier associated withe the child. |
| 92 | + */ |
57 | 93 | - (id<ASLayoutable>)childForIdentifier:(NSString *)identifier; |
| 94 | + |
| 95 | +/** Returns all children added to this layout spec. */ |
58 | 96 | - (NSArray *)children; |
59 | 97 |
|
60 | 98 | @end |
0 commit comments