iOS XML编写器类 [英] iOS XML writer class

查看:66
本文介绍了iOS XML编写器类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个使用关卡系统的游戏。所以我想存储我的关卡并且能够在比赛期间更改它们(以保存状态)。所以我决定使用XML来存储关卡。我发现NSXmlParser类用于从XML读取,但我找不到保存级别状态的编写器。在我的游戏中,关卡状态和关卡非常相似(我有很多可移动的对象),所以我不想存储与它所属的关卡分开的关卡状态数据。问题是我无法找到一种方法来轻松修改iPhone上的XML文件。也许我使用的方法很糟糕。

I want to create a game, that will use a level system. So i want to store my levels and to be able to change them during the game (to save the state). So i decided to use XML for storing levels. I found NSXmlParser class for reading from XML, but i can't find a writer to save the level state. In my game the level state and the level are very similar ( i have a lot of movable objects), so i don't wan't to store the level state data separated from the level it belongs. The problem is that i can't find a way to easily modify XML files on iPhone. Maybe i'm using a bad approach.

推荐答案

你可以使用C libary libxml2 读写XML。这是一个快速介绍: Cocoa Samurai:获取一些XML喜欢libXML2

You can use the C libary libxml2 to read and write XML. Here's a quick intro: Cocoa Samurai: Getting Some XML Love with libXML2.

但是,您是否考虑过使用CoreData或实施 NSCoding 协议? NSCoding 将更容易添加到现有类。

However, have you considered using CoreData or implementing the NSCoding protocol? NSCoding would be easier to add to existing classes.

这篇关于iOS XML编写器类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆