summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSString+MGLAdditions.h
blob: 75c593c10b6020d5c44d88e1a078ea838280e9e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSString (MGLAdditions)

/** Returns the range spanning the entire receiver. */
- (NSRange)mgl_wholeRange;

/** Returns the receiver if non-empty or nil if empty. */
- (nullable NSString *)mgl_stringOrNilIfEmpty;

/**
 Returns a title-cased representation of the receiver using the specified
 locale.

 @param locale The locale. For strings presented to users, pass in the current
    locale (`+[NSLocale currentLocale]`). To use the system locale, pass in
    `nil`.
 */
- (NSString *)mgl_titleCasedStringWithLocale:(NSLocale *)locale;

/**
 Returns a transliterated representation of the receiver using the specified
 script. If transliteration fails, the receiver will be returned.

 Only supports scripts for languages used by Mapbox Streets.

 On iOS 8 or older, this will method will always return the untransliterated
 receiver.

 @param script The four-letter code representing the name of the script, as
    specified by ISO 15924.
 */
- (NSString *)mgl_stringByTransliteratingIntoScript:(NSString *)script;

@end

@interface NSAttributedString (MGLAdditions)

/** Returns the range spanning the entire receiver. */
- (NSRange)mgl_wholeRange;

/** Returns a copy of the receiver with leading and trailing members of the given set removed. */
- (NSAttributedString *)mgl_attributedStringByTrimmingCharactersInSet:(NSCharacterSet *)set;

@end

NS_ASSUME_NONNULL_END