//
//  NSString+save.m
//  SmartLightForBigFish
//
//  Created by coderYK on 2017/9/13.
//  Copyright © 2017年 RD. All rights reserved.
//

#import "NSString+safe.h"

@implementation NSString (safe)

- (NSString *)rds_getSubStringSafetyWithRange:(NSRange)range {
    
    if (self.length >= range.location+range.length) {
        return [self substringWithRange:range];
    }
    return nil;
}

- (NSString *)rds_getSubStringSafetyWithByteLoc:(NSUInteger)location andByteLen:(NSUInteger)length {
    
    return [self rds_getSubStringSafetyWithRange:NSMakeRange(location*2, length*2)];
}

- (NSString *)rds_substringFromIndex:(NSUInteger)from{
    if (self.length >= from) {
        return [self substringFromIndex:from];
    }
    return nil;
}
@end
