mirror of
https://github.com/leanote/leanote-ios.git
synced 2026-01-15 07:01:16 +08:00
Update AFNetworking to 4.0 NSURLProtocol+WebKitSupport.h for WKWebView https://github.com/Yeatse/NSURLProtocol-WebKitSupport
33 lines
821 B
Objective-C
33 lines
821 B
Objective-C
#import "NSString+Util.h"
|
|
|
|
|
|
@implementation NSString (Util)
|
|
|
|
- (bool)isEmpty {
|
|
return self.length == 0;
|
|
}
|
|
|
|
- (NSString *)trim {
|
|
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
|
|
return [self stringByTrimmingCharactersInSet:set];
|
|
}
|
|
|
|
- (NSNumber *)numericValue {
|
|
return [NSNumber numberWithUnsignedLongLong:[self longLongValue]];
|
|
}
|
|
|
|
- (CGSize)suggestedSizeWithFont:(UIFont *)font width:(CGFloat)width {
|
|
CGRect bounds = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: font} context:nil];
|
|
return bounds.size;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation NSObject (NumericValueHack)
|
|
- (NSNumber *)numericValue {
|
|
if ([self isKindOfClass:[NSNumber class]]) {
|
|
return (NSNumber *)self;
|
|
}
|
|
return nil;
|
|
}
|
|
@end |