Gamecenter display names have quotation marks added in release mode

game-center, ios, ipad, iphone

Solution

The `displayName` property actually picks between the nickname (or alias) and the player's actual name. If you are friends with the player you will get their name and the nickname is shown if you are not friends with them. I guess the quotation marks are there to make it clearer which is being displayed. You'll find that the normal GC leaderboards have quotation marks too. There is also `[GKPlayer alias]` which will always give you the nickname (not sure if it is with or without quotes) although the docs say that you shouldn't normally use this. `displayName` is new in iOS6 so I assume that this is considered the correct value to use.

Problem

I have been testing my gamecenter app with sandbox accounts and didn't notice such an issue, in release mode `[GKPlayer displayName]` adds quotation marks to the nickname. So `userNickname` becomes `"userNickname"` and it looks quite bad in name displays and start and end animations. Is it true for all gamecenter versions and users, if so I will simply remove quotation marks. Or should I use something else than `displayName` for fetching the nicknames in iOS 6/7? SOLUTION: I wrote this little function for trimming double quotes in the display names. It turns out they are not regular quotation marks. ``` -(NSString *) trimUnnecessaryCharsInGameCenterDisplayName:(NSString *) displayName { return [displayName stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\u200e\u201c\u201d\u202a\u202c"]]; } ```

Original source