diff --git a/quickdialog/QRadioElement.h b/quickdialog/QRadioElement.h index fdc8ac48..d8c35e3c 100644 --- a/quickdialog/QRadioElement.h +++ b/quickdialog/QRadioElement.h @@ -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; diff --git a/quickdialog/QRadioElement.m b/quickdialog/QRadioElement.m index 018dea4d..59014f0f 100644 --- a/quickdialog/QRadioElement.m +++ b/quickdialog/QRadioElement.m @@ -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){ diff --git a/quickdialog/QRadioSection.h b/quickdialog/QRadioSection.h index 6974906f..5b490f17 100644 --- a/quickdialog/QRadioSection.h +++ b/quickdialog/QRadioSection.h @@ -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 \ No newline at end of file diff --git a/quickdialog/QRadioSection.m b/quickdialog/QRadioSection.m index 8a4bcc07..1ed64037 100644 --- a/quickdialog/QRadioSection.m +++ b/quickdialog/QRadioSection.m @@ -21,7 +21,6 @@ @implementation QRadioSection @synthesize selected = _selected; - - (void)createElements { for (NSUInteger i=0; i< [_items count]; i++){ diff --git a/sample/SampleDataBuilder.m b/sample/SampleDataBuilder.m index 8d51f4eb..60e7d1b3 100644 --- a/sample/SampleDataBuilder.m +++ b/sample/SampleDataBuilder.m @@ -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]; @@ -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; }