动态生成数据成员 [英] Dynamic generation of data members

查看:63
本文介绍了动态生成数据成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个可以独立于其标记解析给定xml文件的应用程序。它在列表单级别的xml文件中工作得很好。我想在对象上分配xml值。由于xml可以是不同的,所以类也必须是通用的,数据成员也必须。我可以使用数据类型id来实现通用数据成员。但问题是不同的xml可以有不同数量的数据类型。那么可以在运行时决定数据成员的数量吗? (这里我加载xml两次是否有助于实现我们的目标?)

I have made one application which can parse the given xml file independent of its tags . It is working well and good for at list single level of xml file .I want to assign the xml values on the object.As xml can be different the class also must be generic one and the data members also . I can achieve the generic data members by using the data type id. But problem is different xml can have different number of data types. so is it possible to decide the number of data members at the run time ? (here i am loading the xml two time is it any way useful to achieve our goal?)

推荐答案

Key -Value Coding 完全符合您的需求,如果您想快速购买,可以使用NSMutableDictionary。简单。

Key-Value Coding perfectly matches your need, you can rather use NSMutableDictionary if you want something quick & simple.

这篇关于动态生成数据成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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