Hello, I'm working on an Objective-C/Cocoa roguelike, because I've always found that working on a game is the best way to learn about a language. I've gotten quite far with my game, but I'm having a problem.
Each level.plist is defined with a few things, like so:
<key>Save Location</key>
<integer>0</integer>
It's grabbed like so, I'd also like to say that this code is all working fine:
NSObject* level = [mapDictionary_ objectForKey: kLevelNumberKey];
However, in my NSLog
-exploring, I've found that instead of grabbing me an integer, or even a useful number, this grabs me an object of some sort, which returns the correct value when NSLogged. How would I go about making this value into an integer so that I can use it like I'd want to be? Note that I've only used NSObject*
because nothing else worked right. If I used =(int)
instead I would get the pointer value or whatever (1108608
for example).
I'm sure it's a simple solution, and I thank you in advance. If you would not mind explaining exactly what is happening, that would be great. My grasp of the concepts is fine, better than most newcomers, but I'm always interested in exactly what is happening. What use would learning to program be if I didn't know what was going on! Please be more than willing to advise me of other situations like this to watch out/be ready for as well. Any advice, really is appreciated, and will be going to somebody who intends to code for a very long time. I put off learning this much too long, my only regret is not starting earlier.
If, for whatever reason, you are interested in trying out my game so far: Link I'm currently in the process of implementing state-saving so that levels remain as you left them. It's obviously OS X only. I'm pretty proud of it so far, but I have a long ways left. The controls are listed in the app.