iOS Loads Instance Code for Bundle File

  • 2021-08-31 09:27:23
  • OfStack

Needless to say, let's introduce the method of loading Bundle file by iOS through 1 code. The specific code is as follows:


- (NSString *)loadJsFile:(NSString *)fileName Type:(NSString *)type{
  NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:type];
  NSString *string1 = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
  NSString *string1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:path] encoding:NSUTF8StringEncoding error:nil];
  return jsScript;
}

Related articles: