开发者

Multiple Copies of a Core Data Object in a UITableView

I'm making a simple UITableView Based game.

It consists of Encounters, which contains Characters & Monsters (both of which contain a set of game stats), and will have a few controls in the cells for interacting with those characters and monsters.

Characters will, by their object definition, only exist in an encounter once. A monster may be represented multiple time (For instance, the player's hero may be facing off against 3 Orc Battle-rager and 2 Goblin Hexers, but each of those are in the database开发者_开发知识库 once, I just want two or three copies of them for a given encounter.

So I'm drawing a bit of a blank figuring out how to model this in the application. Basically I want to have a database of monsters, but when the user creates and encounter they select a monster, input how many they want, and end up with that many copies of the monster who can be interacted with individually


So, the user sees a dialog and selects some number of monsters and then the user is taken to a UITableView to confront those monsters?

If so, it sounds like you want a 'class' of monster and an arbitrary number of 'instances' of a given class. Your Core Data objects would be used to generate individual monsters which, themselves, would be not need to be NSManagedObjects.

If you are planning on having one UITableViewCell for each monster, then you might want to subclass UITableViewCell and (conceptually) instantiate as many of these as there are monsters. If you have more monsters than can be displayed in UITableView, then you would want to use standard approach for reusing cells.

What seems to be lacking is a model of a monster - something that can be added to an array and used to populate a UITableView.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜