Skip to content

Commit

Permalink
Adds constructor with a dictionary, issue escoz#84
Browse files Browse the repository at this point in the history
  • Loading branch information
escoz committed Mar 26, 2012
1 parent fe931b6 commit 329c50c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions quickdialog/QRadioElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
@property(nonatomic, assign, readwrite) NSInteger selected;
@property(nonatomic, retain) NSArray *values;

- (QRadioElement *)initWithDict:(NSDictionary *)valuesDictionary selected:(int)selected title:(NSString *)title;

- (void)setSelectedValue:(NSObject *)aSelected;

- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)selected;
Expand Down
10 changes: 10 additions & 0 deletions quickdialog/QRadioElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ - (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)sele
return self;
}


- (QRadioElement *)initWithDict:(NSDictionary *)valuesDictionary selected:(int)selected title:(NSString *)title {
self = [self initWithItems:valuesDictionary.allKeys selected:(NSUInteger) selected];
_values = valuesDictionary.allValues;
self.title = title;
return self;
}



- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)selected title:(NSString *)title {
self = [super init];
if (self!=nil){
Expand Down
1 change: 1 addition & 0 deletions quickdialog/QRadioSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
- (QRadioSection *)initWithItems:(NSArray *)stringArray selected:(NSUInteger)selected title:(NSString *)title;


- (QSection *)initWithDict:(id)valuesDictionary selected:(int)selected title:(NSString *)title;
@end
1 change: 0 additions & 1 deletion quickdialog/QRadioSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ @implementation QRadioSection

@synthesize selected = _selected;


- (void)createElements {

for (NSUInteger i=0; i< [_items count]; i++){
Expand Down
3 changes: 2 additions & 1 deletion sample/SampleDataBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ + (QElement *)createRadioRoot {
QSection *section1 = [[QSection alloc] initWithTitle:@"Radio element with push"];
[section1 addElement:[[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0]];
[section1 addElement:[[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0 title:@"Sport"]];
[section1 addElement:[[QRadioElement alloc] initWithDict:[NSDictionary dictionaryWithObjectsAndKeys:@"FerrariObj", @"Ferrari", @"McLarenObj", @"McLaren", @"MercedesObj", @"Mercedes", nil] selected:0 title:@"With Dict"]];

QRadioElement *elementWithAction = [[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Ferrari", @"McLaren", @"Lotus", nil] selected:0 title:@"WithAction"];
elementWithAction.controllerAction = @"exampleAction:";
[section1 addElement:elementWithAction];
Expand All @@ -262,7 +264,6 @@ + (QElement *)createRadioRoot {
QSection *section2 = [[QRadioSection alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0 title:@"Sport"];
[root addSection:section2];


return root;
}

Expand Down

0 comments on commit 329c50c

Please sign in to comment.