Sign in to follow this  
Decept

How to convert C# string to Obj-C string

Recommended Posts

I'm making a level editor in C# for my Obj-C iPhone game. Now I need to save strings with filenames in the level file (binary data) and have them loaded on the iPhone. How should I save and load the strings? Also, I don't have much use for other encodings than latin ascii, as these are filenames. But it would be nice to be able to save unicode strings later on for in-game text.

Share this post


Link to post
Share on other sites
I know there is a way to get an UTF8 byte array in .NET, I'm thinking it is this class here. According to a quick google search that gave this, if that is an Obj-C string(never messed with Obj-C), you should be able to create the NSString from the UTF8 byte array.

I know nothing about Obj-C, so don't take this for gospel.

Share this post


Link to post
Share on other sites
[NSString stringWithUTF8String] is your friend in this case. You could mess around with ASCII instead, but this should be a lot more robust (particularly if you need to deal with unicode strings at some point in the future).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this