IOS - Localized JSON Resource

I have a JSON resource resource.json in the my / MyApp / Resources / folder. I want this resource to be localized, so I chose to localize it in Swedish and English in Xcode. Now I have 2 folders:

/MyApp/Resources/sv.lproj/resource.json

and

/MyApp/Resources/en.lproj/resource.json

So far so good. But whenever I try to use this resource with:

NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"resource" ofType:@"json"]; NSString *jsonString = [NSString stringWithContentsOfFile:jsonPath encoding:NSUTF8StringEncoding error:&error]; 

jsonString will always contain the English version of the resource. I tried switching languages ​​both in the simulator and on the device to no avail.

I am not sure how to fix this problem ...

+4
source share
1 answer

After uninstalling the application, clean and compile it.

+2
source

Source: https://habr.com/ru/post/1447944/


All Articles