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任何人都可以幫助解決它?