SoFunction
Updated on 2025-04-12

iOS instance code to load Bundle file

I won’t say much nonsense. Here is a code to introduce to you the method of loading Bundle files on iOS. 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;
}

The above is the example code for loading Bundle files on iOS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!