2. 是谁调了我的底层库
# define LEFLog(fmt, ...) NSLog((@"%s (%d) => " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)@implementation LEFLog
+ (NSString *)lastCallMethod
{
NSArray *symbols = [NSThread callStackSymbols];
NSInteger maxCount = symbols.count;
NSString *secondSymbol = maxCount > 2 ? symbols[2] : (maxCount > 1 ? symbols[1] : [symbols firstObject]);
if (secondSymbol.length == 0) {
return @"";
}
NSString *pattern = @"[+-]\\[.{0,}\\]";
NSError *error;
NSRegularExpression *express = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:&error];
if (error) {
NSLog(@"Error: %@", error);
return @"";
}
NSTextCheckingResult *checkResult = [[express matchesInString:secondSymbol options:NSMatchingReportCompletion range:NSMakeRange(0, secondSymbol.length)] lastObject];
NSString *findStr = [secondSymbol substringWithRange:checkResult.range];
return findStr ?: @"";
}
@endLast updated
Was this helpful?