// // NSString+MT.m // // Created by Simon on 2019/3/22. // Copyright © 2019 Simon. All rights reserved. // #import "NSString+MT.h" @implementation NSString (MT) /** * URLEncode */ - (NSString *)URLEncodedString { // CharactersToBeEscaped = @":/?&=;+!@#$()~',*"; // CharactersToLeaveUnescaped = @"[]."; NSString * charaters = @"?!@#$^&%*+,:;='\"`<>()[]{}/\\| "; NSCharacterSet * set = [[NSCharacterSet characterSetWithCharactersInString:charaters] invertedSet]; return [self stringByAddingPercentEncodingWithAllowedCharacters:set]; } /** * URLDecode */ -(NSString *)URLDecodedString { return [self stringByRemovingPercentEncoding]; } - (CGFloat)computeStringHeight{ return [self boundingRectWithSize:CGSizeMake(ScreenWidth - kNumFrom375(30), 99999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kNumFrom375(14)]} context:nil].size.height+2; } @end