Après section de code résultats magnifiquement: - (void)setRepresentedObject:(id)representedObject { DLOG()
NSRegularExpression: stringByReplacingMatchesInString ne reconstruit pas la chaîne avec plusieurs lignes
- (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);
}
Mais au lieu de mettre une seule ligne d'entrée dans la chaîne variable si je tente pour lire un fichier de code dit fichier ViewController.m qui contient le code suivant et le mettre dans cette variable: cela ne fonctionne pas.
//
// 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 affiche la même chose que l'entrée. DLog() non apposé Quelqu'un peut-il aider à le résoudre?