简体   繁体   English

MySQL数据到objective-c对象

[英]MySQL data to objective-c object

I'm wondering how to take data from a remote MySQL database and parse it into an objective-c object. 我想知道如何从远程MySQL数据库中获取数据并将其解析为Objective-C对象。 For example, if I have a list of food in my database, and each food item has certain properties, like a name, price, description, how would I parse each item in the database to a food object class in objective c. 例如,如果我在数据库中有一个食物列表,并且每个食物项目都有某些属性,例如名称,价格,描述,我将如何将数据库中的每个项目解析为目标c中的一个食物对象类。

I usually parse XML which iterates over each food item, so that I can do things like food.description to get the food's description... 我通常会解析对每个食品项进行迭代的XML,以便我可以执行food.description之类的操作来获取食品的描述...

Currently I can acquire my data using php and storing it in JSON. 目前,我可以使用php获取数据并将其存储在JSON中。 I the use the JSONtouch library to parse it. 我使用JSONtouch库进行解析。 How could I use a similar structure but taking the data above and translating it into an object? 我如何使用类似的结构,但将上面的数据转换为对象?

Thanks! 谢谢!

Take a look at GNUstep's GDL2 library, to see whether it will work for you (and whether the license is acceptable). 查看GNUstep的GDL2库,看它是否对您有用(以及许可证是否可接受)。 It's an ORM library that supports MySQL among other data sources. 这是一个支持MySQL以及其他数据源的ORM库。

Otherwise, you could wrap the MySQL client library in an NSIncrementalStore subclass to use it via Core Data. 否则,您可以将MySQL客户端库包装在NSIncrementalStore子类中,以通过Core Data使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM