mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Objective-C
		
	
| //
 | |
| //  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | |
| //
 | |
| 
 | |
| #import "NSString+OWS.h"
 | |
| #import "UIView+OWS.h"
 | |
| 
 | |
| NS_ASSUME_NONNULL_BEGIN
 | |
| 
 | |
| @implementation NSString (OWS)
 | |
| 
 | |
| - (NSString *)ows_stripped
 | |
| {
 | |
|     return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
 | |
| }
 | |
| 
 | |
| - (NSString *)rtlSafeAppend:(NSString *)string referenceView:(UIView *)referenceView
 | |
| {
 | |
|     OWSAssert(string);
 | |
|     OWSAssert(referenceView);
 | |
| 
 | |
|     return [self rtlSafeAppend:string isRTL:referenceView.isRTL];
 | |
| }
 | |
| 
 | |
| - (NSString *)rtlSafeAppend:(NSString *)string isRTL:(BOOL)isRTL
 | |
| {
 | |
|     OWSAssert(string);
 | |
| 
 | |
|     if (isRTL) {
 | |
|         return [string stringByAppendingString:self];
 | |
|     } else {
 | |
|         return [self stringByAppendingString:string];
 | |
|     }
 | |
| }
 | |
| 
 | |
| - (NSString *)removeAllCharactersIn:(NSCharacterSet *)characterSet
 | |
| {
 | |
|     OWSAssert(characterSet);
 | |
| 
 | |
|     return [[self componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
 | |
| }
 | |
| 
 | |
| - (NSString *)digitsOnly
 | |
| {
 | |
|     return [self removeAllCharactersIn:[NSCharacterSet.decimalDigitCharacterSet invertedSet]];
 | |
| }
 | |
| 
 | |
| @end
 | |
| 
 | |
| NS_ASSUME_NONNULL_END
 |