iOS app localization - iphone

I want to localize my app. Should I create a new app in itunesconnect for each country or there is a way to automatically detect the country where user is? Actually my app is game based on Unity3d - is it possible to do it on Unity3d?

Before Unity starts write these lines to pass the current language into unity
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:#"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject: preferredLang forKey: #"language"];
[[NSUserDefaults standardUserDefaults] synchronize];

Definitely don't create a new app for each locale. iOS apps are localizable and iTunes Connect allows you to enter different metadata for each language.

You dont need to make a new app for each language. Try following a guide like SmoothLocalize's tutorial or This one.
Then you'll have a Localizable.strings file you need to translate. I usually use SmoothLocalize.com as my translation services, because its cheap and super easy, but you can look around for others or even try to find individual translators yourself.

Related

Reading Data from Today Extension (NSUserDefaults) works on Simulator but not in Device

I managed to read data in a Today Extensions from the companion app with code like
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.cdm.TodayExtensionSharingDefaults"];
NSData *encodedObject = [defaults objectForKey:#"DataContactList"];
CV_DataContactList *object = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
with the corresponding writing code in the companion app
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.cdm.TodayExtensionSharingDefaults"];
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:self];
[defaults setObject:encodedObject forKey:#"DataContactList"];
[defaults synchronize];
I created the app group and added in the Capabilities of both target (extension and companion app).
All is working fine in the simulator and data are passed as soon as the companion app changes them.
But when I run the extension on the device it cannot read any data. I got the
<Warning>: *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL on the console log.
I tried to also generate provisioning profiles, with right appid and app group, from scratch but it didn't solve.
I appreciate any help. Thanks!
Try adding the class file where you save your data in TodayExtension target > Build Phases > Compile Sources. You have add only the .m files in it.
For example:
If the data saved file is MyData.m check if that file is presented in Target of your project and today extn target.
If this doesn't work and any of you have already found the solution please add it so it will be helpful later.

How to save highscore and load highscore in a cocos2d iphone game

I have made my first iPhone game and i have it in the beta testing stage, but then i realised i am missing high score. I don't know how to add high score into the game and if anyone could help me it would be greatly appreciated, also could you tell me if it goes in the game scenes .m or .h file and where to declare it cheers.
Also i have tried to do this before and failed.
The best way to achieve this is using game center. It's very simple to integrate.
You could:
Use NSUserDefaults
Use plists
Use CoreData
If it is just a numerical value you want to store, defaults and plist are fine. But in case you want to store high scores, names, times, and/or scores of many/other users, et cetera, I would suggest using CoreData.
To save some data :
[[NSUserDefaults standardUserDefaults]setObject:yourNumber forKey:#"HighScore"];
to read it :
int high=[[NSUserDefaults standardUserDefaults]objectForKey:#"HighScore"];
This is objective c, cocos2d does not have some special way to save the data for you .
You better not use the game center only, but keep some copy at the user defaults .
First way: look at the plist this is the best way to store highscore load whatever your highScore into Plist and then retrieve that highscore from plist whenever you need. Look at this tutorial: Look at this tutorial
Second way is to store your highscore into NSUSerDefault and retrieve when you want.
NSuserDefault only vanish when you delete the app from simulator or device. So this is also solution for you..
Look at this
Save data to default:
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
[def setObject:highScore forKey:#"High Score"];
[def synchronize];

creating in-app settings for iPad applications

I want to create in-app settings for my iPad application. There are different alerts for different groups, so the user can select which alerts he/she wants in the application. I am putting a custom button which will look like checkbox so when user will click it, it will be highlighted.
Can anyone tell me where can I store the settings, do I need to save settings in keychain or somewhere else? Is there any tutorial for doing that?
I've found NSUserDefaults very helpful for stuff like this. Basically you do this to store values:
NSUserDefaults* defaults= [NSUserDefaults standardUserDefaults];
[defaults setBool:yourBool forKey:#"yourBoolKey"];
[defaults setInteger:yourInteger forKey:#"yourIntegerKey"];
[defaults synchronize];
And to get values:
NSUserDefaults* defaults= [NSUserDefaults standardUserDefaults];
yourBool= [defaults boolForKey:#"yourBoolKey"];
yourInteger= [defaults integerForKey:#"yourIntegerKey"];
To have default settings when the app first launches, you could just check a bool with the key #"AppHasStoredSettings" or something like that, which will be NO the first time, set your default settings, and then set it to YES.
The best thing would probably be a plist, which, in reality is a structured XML file with keys and values, but Apple abstracts most of that for you pretty well with some nice settings tools. Here's a few things to peruse to get a handle on the idea:
NSUserDefaults
User Defaults Programming Topics
Information about property list files
Luke put some helpful code, but look at these too for more examples and ways to use all the tools available.

iPhone: Problems after application submission in AppStore

I've submitted my first iPhone App to the AppStore (on 10.09.10) and I have just found out that it was "Ready For Sale" (18.09.10). After a short moment of deep Happiness, I've found out some problems in my App, that I DO NOT have when I install it on my iPhone using XCode:
1) My APP uses the CLLocationManager to get the GPS coordinates. I've already tested it and it works very well, but after downloading my App from AppStore, I've noticed that my App DOES NOT get any coordinates. Normally, after installing a new App on my iPhone, that needs to get the GPS coordinates, the iOS asks me if I want to allow that App to do so, but in the case with my App, the iOS does not ask me that question. Am I missing something?
P.S.: As I submitted my App to the Review-process I did NOT select the option which says that my App "needs the location services" (UIRequiredDeviceCapabilities in my Info.plist). Do you think this was a mistake?
2) I have some "boolean buttons". When the user clicks on the button, it makes a sound. But in the AppStore version, it does not make ANY sound (even the sounds the picker makes when a picturen is taken can not be heard). Here is my method:
- (void) playMCSound:(BOOL)release {
//Get the filename of the sound file:
NSString *path;
if (release) {
path = [NSString stringWithFormat:#"%#%#",
[[NSBundle mainBundle] resourcePath],
#"/releaseClick.wav"];
} else {
path = [NSString stringWithFormat:#"%#%#",
[[NSBundle mainBundle] resourcePath],
#"/cllick.wav"];
}
//declare a system sound id
SystemSoundID soundID;
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
//Use audio sevices to create the sound
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
//Use audio services to play the sound
AudioServicesPlaySystemSound(soundID);
}
Is something wrong with this method? (as I said: it works normally when I install the App using XCode)
My App is "KA Feedback", by the way. But it is only available in Germany.
I would appreciate any suggestion.
With respect to #1, check in the location services settings next to your app name, if location permission is "on" or "off", it's probably in the off position.
And for #2, while this may sound really silly, I have to ask that first, is the volume turned up when you're in say, the iPod app? I'm not talking about the ringer volume, but the volume of audio apps. Check that first. If it is indeed non-mute, then check in your distribution build, that releaseClick.wav (which is what I presume is supposed to be loaded) exists, and is being copied into the app bundle.

Change the Locale of MKReverseGeocoder's response?

I noticed that MKReverseGeocoder returns the country / city / etc. names in the locale of the iPhone's currentLocale. Is there a way to set the currentLocale, or to set the NSLocale instance that a reverseGeocoder is using?
Yes there is, I had the same problem and used this code to great effect:
("en" is for english for example.)
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:#"en", nil] forKey:#"AppleLanguages"];
You may or may not synchronize at some point or straight after:
[[NSUserDefaults standardUserDefaults] synchronize];
Now there are a couple of notes on this:
This will work if for example you are in London and have set your iPhone in another language, it will always return geo names in English.
What I haven't tested yet but I've seen some odd behaviour is that if have set english as you language but you are abroad (IE Denmark, I was once on a trip to DK) and noticed the revgeocoding was in danish, but this was before I've used that magic line of code. Still with my iPhone in english in Denmark I was expecting english results but no cigar at that time.