开发者

What's a good way to store simple data that's used by a Command Line?

开发者 https://www.devze.com 2023-04-11 07:52 出处:网络
I\'m new to both Mac and the C programming language; but, I recently installed Xcode, and I\'ve been trying to figure somethings out..

I'm new to both Mac and the C programming language; but, I recently installed Xcode, and I've been trying to figure somethings out..

Currently I want to work on making a small Command Line game. But I need to find a good way to store simple data, like strings and integers..

So, is there a way to store information in an XML f开发者_StackOverflow中文版ile through C? If so, would that be a good way to go about things? If not, what do you suggest?


For simple data you can use NSUserDefaults.

Example where 32 is the:

int score = 32.
[[NSUserDefaults standardUserDefaults] setInteger:score forKey:@"CurrentScore"];

later:

score = [[NSUserDefaults standardUserDefaults] integerForKey:@"CurrentScore"];

See the documentation for NSUserDefaults, it can handle many types of data.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号