Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will I be able to restart my iPhone app programatically to apply language changes in Swift [duplicate]

I am developing an iPhone app in swift and wanted localisation feature inside it. When the user selects a language in the app, the UI components such as labels/buttons,etc.,. fails to change the language and takes more time in some cases also. So i needed to manually restart my app when the users want to change the language. Can anyone please suggest me how to do that. Thanks in advance.

like image 478
Muralidharan Kathiresan Avatar asked Dec 03 '14 04:12

Muralidharan Kathiresan


2 Answers

Swift is a language, not an API. You have the same functionality available to you in Swift as in Objective C, although the syntax and ease of use may differ between the languages.

The answer you linked to therefore already answers the question.


Also, as Hemang points out, don't do this.

It's symptomatic of bad design that you would need to restart the app to change the displayed language. It would be much better to fix the underlying problem than to apply a hacky band-aid solution such as this.

like image 136
sapi Avatar answered Sep 29 '22 21:09

sapi


DONT EVER DO THIS... else you'll surely reject by Apple, I don't know what problem you're facing after user change different language from your app, because I'd worked on this kind of app before (which supports multiple language and user may able to change it while current running of the app). I don't have idea with Swift but in ObjectiveC it works perfect.

From Documentation, https://developer.apple.com/library/ios/qa/qa1561/_index.html

Warning: Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen.

NOT RECOMMENDED but still, you can ask user to Restart their app whenever they changed the language with proper message like, " needs to restart to take effect of language change, [please save your any on going work] and close and again open the app to see the effect, thanks !"

Here, the words inside <...> should be your app name, and [...] need to show if you're making an app that needs to save user information before exit?.

like image 28
Hemang Avatar answered Sep 29 '22 20:09

Hemang