i have a bundel settings with a string : version
in my bundle settings version = 2.9.1
in my project, if i use this code, all is good :
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"ma/V_2.9.1/gma2/fixture_layers/ifocus.xml"];
if i use this code :
NSString *path = [documentsDirectory stringByAppendingPathComponent:(@"ma/V_%@/gma2/fixture_layers/ifocus.xml", version)];
i have this error :
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField length]: unrecognized selector sent to instance 0x9753190'
NSString * path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@“ ma/V_%@/gma2/fixture_layers/ifocus.xml”,版本]];
Since you're already including multiple /'s in your string, there's no advantage to using stringByAppendingPathComponent. So you may as well just use:
NSString* path = [documentsDirectory stringByAppendingFormat:@"ma/V_%@/gma2/fixture_layers/ifocus.xml", version];
Another option, that gives you the benefit of stringByAppendingPathComponent, is to break it right down like this:
NSString* path = [[[[[documentsDirectory stringByAppendingPathComponent:@"ma"] stringByAppendingPathComponent:[NSString stringWithFormat:@"V_%@", version]] stringByAppendingPathComponent:@"gma2"] stringByAppendingPathComponent:@"fixture_layers"] stringByAppendingPathComponent:@"ifocus.xml"];
But that's kind of ugly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.