0
继代码段重建串精美的结果: - (void)setRepresentedObject:(id)representedObject { DLOG()
NSRegularExpression:stringByReplacingMatchesInString不能与多行
- (void) putLogInFunctionCalls{
NSString *string = @"- (void)setRepresentedObject:(id)representedObject {";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^-[^{]+\{" options:NSRegularExpressionCaseInsensitive error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:[NSString stringWithFormat:@"%@ DLOG()", string]];
NSLog(@"%@", modifiedString);
}
但不是把只是一个线路输入的变量字符串,如果我尝试阅读代码文件说,ViewController.m文件,其中包含以下代码,并将其放在该变量:它不起作用。
//
// ViewController.m
// ForCommonCoding
//
// Created by A Programmer on 7/6/17.
// Copyright ? 2017 A Programmer. All rights reserved.
//
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];
// Update the view, if already loaded.
}
- (void)sampleFunction {
NSLog(@"This is sampleFunction");
}
@end
NSLog显示与输入相同。 DLog()没有appendded任何人都可以帮助解决它?