mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
34 lines
1.0 KiB
Objective-C
Executable File
34 lines
1.0 KiB
Objective-C
Executable File
//
|
|
// NSString+Stripe.m
|
|
// Stripe
|
|
//
|
|
// Created by Jack Flintermann on 10/16/15.
|
|
// Copyright © 2015 Stripe, Inc. All rights reserved.
|
|
//
|
|
|
|
#import "NSString+Stripe.h"
|
|
|
|
@implementation NSString (Stripe)
|
|
|
|
- (NSString *)stp_safeSubstringToIndex:(NSUInteger)index {
|
|
return [self substringToIndex:MIN(self.length, index)];
|
|
}
|
|
|
|
- (NSString *)stp_safeSubstringFromIndex:(NSUInteger)index {
|
|
return (index > self.length) ? @"" : [self substringFromIndex:index];
|
|
}
|
|
|
|
- (NSString *)stp_reversedString {
|
|
NSMutableString *mutableReversedString = [NSMutableString stringWithCapacity:self.length];
|
|
[self enumerateSubstringsInRange:NSMakeRange(0, self.length)
|
|
options:NSStringEnumerationReverse | NSStringEnumerationByComposedCharacterSequences
|
|
usingBlock:^(NSString *substring, __unused NSRange substringRange, __unused NSRange enclosingRange, __unused BOOL *stop) {
|
|
[mutableReversedString appendString:substring];
|
|
}];
|
|
return [mutableReversedString copy];
|
|
}
|
|
|
|
@end
|
|
|
|
void linkNSStringCategory(void){}
|