willzeng
willzeng

Reputation: 935

Can a player identifier string be used as a filename in iOS?

Words above are from Apple's Game Kit Programming Guide when introducing Game Center. But I have to make at least one assumption, that is, a player identifier string can always be used as a filename in iOS. The reason is simple, I have to know which player's data file to load once I get the player's identifier string.

Can this be guaranteed? If not, is there any alternative that achieves the same purpose?

Upvotes: 1

Views: 128

Answers (1)

Alex Deem
Alex Deem

Reputation: 4805

If you're concerned about the player identifier string containing characters that cannot be used in a filename, the simplest thing to do would be to URL encode it first.

For example:

 NSString *encodedFilename = [filename stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Upvotes: 1

Related Questions