-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOWSection.m
62 lines (47 loc) · 1.24 KB
/
OWSection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// OWSection.m
// OWForms
//
// Created by Rodrigo Recio on 24/09/10.
// Copyright 2010 Owera Studio. All rights reserved.
//
#import "OWSection.h"
#import "OWField.h"
@implementation OWSection
@synthesize headerTitle, summary, fields, footerTitle;
+ (id)section {
return [[[self alloc] init] autorelease];
}
+ (id)sectionWithField:(id)aField {
return [self sectionWithArrayOfFields:[NSArray arrayWithObject:aField]];
}
+ (id)sectionWithFields:(id)firstField, ... {
va_list args;
va_start(args, firstField);
id s = [[[self alloc] initWithFields:firstField vaList:args] autorelease];
va_end(args);
return s;
}
+ (id)sectionWithArrayOfFields:(NSArray *)fieldsArray {
id s = [[self alloc] init];
[s setFields:[[fieldsArray mutableCopy] autorelease]];
return [s autorelease];
}
- (id)initWithFields:(OWField *)field vaList:(va_list)params
{
if (self == [super init]) {
fields = [[NSMutableArray alloc] init];
[fields addObject:field];
OWField *f = va_arg(params, OWField *);
while( f ) {
[fields addObject:f];
f = va_arg(params, OWField *);
}
}
return self;
}
- (void)addField:(OWField *)aField {
if (self.fields == nil) self.fields = [[NSMutableArray alloc] init];
[self.fields addObject:aField];
}
@end