0
我想,所以我用这个方式来获得.m文件的源代码:我可以从.m文件获取源代码吗?
NSString *path = [[NSBundle mainBundle] pathForResource:@"ViewController" ofType:@".m"];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@", content);
但是控制台打印“空”。
我想知道是否有任何方法可以用来获取.m文件的内容,即使使用私有方法。
你不能得到它,因为所有的源代码都编译成二进制。您的替代方案是制作源代码的副本,将其重命名为其他扩展名,如.txt并将其添加到您的包中,然后您可以在上面的代码中使用它。 – GeneCode