Skip to content

Fail utils method in UIView (CLUViewRecordableAdditions) if arguments are invalid #6

@Geek-1001

Description

@Geek-1001

Description

We need to fail some utils method in UIView (CLUViewRecordableAdditions) if input arguments are invalid.

For example:

- (NSDictionary *)clue_fontPropertyDictionaryForFont:(UIFont *)font {
    NSMutableDictionary *fontDictionary = [[NSMutableDictionary alloc] init];
    if (font) {
        [fontDictionary clue_setValidObject:font.familyName forKey:@"familyName"];
        [fontDictionary clue_setValidObject:font.fontName forKey:@"fontName"];
        [fontDictionary setObject:@(font.pointSize) forKey:@"pointSize"];
        [fontDictionary setObject:@(font.lineHeight) forKey:@"lineHeight"];
    }
    return fontDictionary;
}

If user will pass invalid font – this method will return empty dictionary. But if font is invalid, we don't need font dictionary at all.
Here are some utils method from UIView (CLUViewRecordableAdditions) which I think needs to be fixed (return nil if input argument is invalid)

  • -clue_fontPropertyDictionaryForFont:
  • -clue_attributedTextPropertyDictionaryForAttributedString:
  • -clue_colorPropertyDictionaryForColor:

Note : We need to check where those method used and ensure that we won't pass invalid object into dictionary for example.

Problem

We don't need empty dictionary if input argument is invalid.

Reference

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions