diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-03-13 17:41:28 -0700 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-03-14 12:59:45 -0700 |
commit | 5056c6075aafefa6ccd399ccb63f3aad0024e1bd (patch) | |
tree | d01a2a45c592ae96ba43176c285a69882d9d4d2e | |
parent | a76a9c749480864b92e0b81c40733a752816ba51 (diff) | |
download | qtlocation-mapboxgl-5056c6075aafefa6ccd399ccb63f3aad0024e1bd.tar.gz |
[ios, macos] Add MGLAttributedExpression class documentation.
-rw-r--r-- | platform/darwin/src/MGLAttributedExpression.h | 23 | ||||
-rw-r--r-- | platform/darwin/src/MGLAttributedExpression.m | 10 |
2 files changed, 29 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLAttributedExpression.h b/platform/darwin/src/MGLAttributedExpression.h index 92d1ef5b99..5f363efc90 100644 --- a/platform/darwin/src/MGLAttributedExpression.h +++ b/platform/darwin/src/MGLAttributedExpression.h @@ -7,16 +7,37 @@ typedef NSString * MGLAttributedExpressionKey NS_EXTENSIBLE_STRING_ENUM; FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontNamesAttribute; FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontSizeAttribute; +/** + An `NSExpression` that has associated text formatting attibutes (such as font size or + font names). + */ MGL_EXPORT @interface MGLAttributedExpression : NSObject +/** + The expression content of the receiver as `NSExpression`. + */ @property (strong, nonatomic) NSExpression *expression; + +/** + The formatting attributes. + */ @property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes; +/** + Returns an `MGLAttributedExpression` object initialized with an expression and no attribute information. + */ - (instancetype)initWithExpression:(NSExpression *)expression; + +/** + Returns an `MGLAttributedExpression` object initialized with an expression and text format attributes. + */ - (instancetype)initWithExpression:(NSExpression *)expression attributes:(nullable NSDictionary <MGLAttributedExpressionKey, id> *)attrs; -+ (instancetype)initWithExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontSize:(nullable NSNumber *)fontSize; +/** + Creates an `MGLAttributedExpression` object initialized with an expression and the format attributes for font names and font size. + */ ++ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontSize:(nullable NSNumber *)fontSize; @end diff --git a/platform/darwin/src/MGLAttributedExpression.m b/platform/darwin/src/MGLAttributedExpression.m index 2d60ebbd2a..715f74e42f 100644 --- a/platform/darwin/src/MGLAttributedExpression.m +++ b/platform/darwin/src/MGLAttributedExpression.m @@ -11,17 +11,17 @@ const MGLAttributedExpressionKey MGLFontSizeAttribute = @"font-scale"; return self; } -+ (instancetype)initWithExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString *> *)fontNames fontSize:(nullable NSNumber *)fontSize { ++ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString *> *)fontNames fontSize:(nullable NSNumber *)fontSize { MGLAttributedExpression *attributedExpression; NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; if (fontNames && fontNames.count > 0) { - [attrs setObject:fontNames forKey:MGLFontNamesAttribute]; + attrs[MGLFontNamesAttribute] = fontNames; } if (fontSize) { - [attrs setObject:fontSize forKey:MGLFontSizeAttribute]; + attrs[MGLFontSizeAttribute] = fontSize; } attributedExpression = [[self alloc] initWithExpression:expression attributes:attrs]; @@ -52,4 +52,8 @@ const MGLAttributedExpressionKey MGLFontSizeAttribute = @"font-scale"; return result; } +- (NSString *)description { + return [NSString stringWithFormat:@"MGLAttributedExpression<Expression: %@ Attributes: %@>", self.expression, self.attributes]; +} + @end |