At the moment, I'm adding a system that uses hashes to prevent cheaters from making my game really easy. However, in order to load a plist into an NSString, I need to know what it's encoded in. Does anyone know?
Plist encoding?
(4 posts) (2 voices)-
Posted 1 year ago #
-
OK, solved my issue through some trial and error, and ended up with a lucky first guess; it's UTF-8. However, unluckily for me, the iPhone has something against loading plists into NSStrings, so now I have a bit of a problem.
Posted 1 year ago # -
Load the plist into a NSMutableDictionary, then get the field that you need as a NSString. If the field is a number then you would have to get the number as NSNumber object. Then, you will do something like [NSString stringWithFormat:@"some number: %d", [SomeNSNumber intValue]].
If you don't know how to retrieve something from a NSMutableDictionary then: [MyDictionary objectForKey@"somekey"];
You should be able to load the plist directly into a NSMutuableDictionary just do a google search and you should find examples of how to do it. I am pretty sure the question has been asked on Stackoverflow, so you can search there also.
Posted 1 year ago # -
The problem is that I needed the whole thing, though; I should've been more clear. However, I just realized that if I change the extension of the file to .txt, both NSString and NSDictionary load it properly without modifying my code at all (and as an added bonus, Xcode still loads loads it in the plist editor, rather than the text editor).
Posted 1 year ago #
Reply
You must log in to post.