Nosrettap
Nosrettap

Reputation: 11340

How to view source code while running iOS app?

I have a UIViewController called simple ViewController. I want it so that when the user presses a button on screen it shows them the code for ViewController.m. How can I do this? I tried

NSString *contents = [NSString stringWithContentsOfFile:@"ViewController.m" encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",contents);

But it keeps returning nullAny ideas?

Upvotes: 0

Views: 212

Answers (1)

Phillip Mills
Phillip Mills

Reputation: 31026

You would need to package the .m file as a resource to be copied into the main bundle of your application during the appropriate build phase and then read it from the bundle to display.

Upvotes: 1

Related Questions