Skip to content

Commit

Permalink
Minor null checking
Browse files Browse the repository at this point in the history
  • Loading branch information
escoz committed May 23, 2013
1 parent 412457a commit 6b48c8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions quickdialog/QBindingEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ - (void)fetchValueFromObject:(QElement *)element toData:(id)data {
NSString *propName = [((NSString *) [bindingParams objectAtIndex:0]) stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *valueName = [((NSString *) [bindingParams objectAtIndex:1]) stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

if (![propName isEqualToString:@"iterate"] && ![valueName isEqualToString:@"self"])
[data setValue:[element valueForKey:propName] forKeyPath:valueName];
if (![propName isEqualToString:@"iterate"] && ![valueName isEqualToString:@"self"]) {
id value = [element valueForKeyPath:propName];
if (propName!= nil && value!=nil)
[data setValue:value forKeyPath:valueName];
}
}

}
@end
@end
5 changes: 4 additions & 1 deletion quickdialog/QRadioElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ -(void)setItems:(NSArray *)items {
}

-(NSObject *)selectedValue {
if (_selected<0 || _selected>=_values.count)
return nil;

return [_values objectAtIndex:(NSUInteger) _selected];
}

Expand Down Expand Up @@ -87,7 +90,7 @@ - (QRadioElement *)initWithDict:(NSDictionary *)valuesDictionary selected:(int)s


-(void)setSelectedItem:(id)item {
if (self.items==nil)
if (self.items==nil || item==nil)
return;
self.selected = [self.items indexOfObject:item];
}
Expand Down

0 comments on commit 6b48c8b

Please sign in to comment.