---
title: WWDC2004 Session 313
framework: wwdc
role: article
path: wwdc/wwdc2004-313
---

# WWDC2004 Session 313

## Transcript

Kind: captions Language: en good morning everybody I'm Chris Espinosa of the Apple developers tools team and I'm here to talk about modeling and design and Xcode I'd like to thank you for coming out at nine o'clock on the Friday morning before a three-day holiday weekend to reward your perseverance we're going to be auctioning off this rack of rare imax your last chance before it sep tember to get some not really we will have something for you at the end of the show though so i'm going to be talking to you about the design and modeling tools and about what models are and what they do for you in your software design process how they're integrated into your workflow in xcode and talk about some of the future directions for design tools as i mentioned on Monday in Ted session we're going we offer two plugins and we're going to be talking about those today but we expect these to be the first two of many to augment your coding workflow with design tools what you're going to learn is how to create navigate the class models whether you're using c++ Objective C or Java how to save and share the class models with other people in your projects how to create a data model for the core data framework build a core data schema from it and deploy an application using it you should know something about object-oriented program if if you're using straight c programming for the command line ur the colonel now would be an excellent time to deplane because this has nothing to do with you but if you do object oriented programming in C++ Objective C or Java stick around you'll learn something it will help to know about core data framework for using the data models if you are not using the core data framework you might want to look into it it's very cool and can be used from either objective-c or from C++ why did we put diagrams in Xcode the thing that really drove it was the core data frame work in that we knew we needed to create schemas for the core data framework and that the best way to see your schema and to understand it and to create it was with a visual model rather than with a big table or a big hunka XML so modeling the data schema for the core data framework was really are driving purpose but we also knew that there was a big missing piece in Xcode in that we didn't have a good class diagram to let you get a bird's eye view of your class hierarchy of your projects we decided if we could kill two birds with one stone and have one diagramming tool that did both that'd be really helpful especially if we could wire it in so you can use it to browse and navigate your code from the diagram rather than just from the class pop-up or the project into the project symbols list diagrams are easier to grok in a large scale than looking at your code or even looking at it in the class browser table wise we wanted to draw you some beautiful pictures not just that you could see and visualize but that you could change and modify yourself so you can use them not just for the tool to communicate to you what your code looks like but for you to communicate to others what your code looks like so models are integrated into Xcode they're not a separate process that you run to take a look at your project they're not a window you pop up in order to see it that's separate from your workflow they're deeply integrated into Xcode to the degree that model files our project files in your project you build them you save them you check them in you commit them and for data model files you even build them in your build process that's how deeply integrated they are they are integrated into the SCM system whether you're using CVS or perforce or subversion so that they can be checked in just like nim files just like project files just like source code files so let's talk first about the class models you probably saw the class models in Ted's presentation on Monday you may not have seen class model since then so we're going to be doing a quite a bit of time with class models today first of all their language agnostic they show c++ Objective C or Java in this first instance as we extend Xcode to deal with more languages as we add more design plugins you'll see class models for other things as well we have a generic UML to based framework underneath so we can model pretty much anything that you want to model right now what you've got on you disk with Xcode 2 point 0 is C++ objective c and java there are two kinds of models because we knew that you'd have different modes working depending upon whether you were really down drilling into your code or whether you just wanted to get an overview of something new so we have quick models which is here's something i want to see it and i don't care if it goes away when i close my session and then there are user models which is here's something I'm really working on I want to hone it I want to tailor it I want to use it as my principal navigation tool and I want you to save that with my project so quick models first quick models are you select something in your project you choose quick model from the menu and it shows you a class diagram it's really simple it's really straightforward you don't have to save it with your project you don't have to commit it to your repository it includes all of the things all of the objects that are in that group you selected and it includes the first parent outside the group doesn't go all the way up the hierarchy so you don't see you know ninety percent foundation dot framework and ten percent your project it only goes to the first root and that's a tool for clarity rather than you know completeness it will model your whole project it'll model a group it'll model a multiple selection of header files or source files it'll model a target and you can pick anything just a quick model the layouts automatic it does a pretty nice view and you can tailor it you can drag things out you can move things around to see them you can use it to navigate but it's not stored with your project so any changes you make or ephemeral it's like a temp file code models can be pretty big so we've given you some navigation tools first there's a zoom out zoom in like any graphic tool so you can get a bird's eye view or you can hone in on a particular class there are tool tips so if you're zoomed out you can actually read it because the type is you know like four points when you're zoomed out there's type select to navigate out so you can type the name in the class and you can find it in the diagram and then zoom in to where it is and you can as you saw in the presentation on Monday you can go directly from the class diagram to the interface declaration to the implementation source code or to the it says class browser but this is in error you can go to the documentation if it happens to be a class that is built in to an apple framework with the class diagrams you can customize them as I mentioned you can expand and collapse the boxes you can drag them to rearrange you do group selects and things like that you can relay out the diagram to get the boxes out laid out nice you can use custom colors in your classes once again for quick models this is more or less irrelevant because these changes aren't saved and then there's the standard graphics tools that you might find in the graphics layout programs such as alignment locking and unlocking things like that so now we're going to give a demo of quick models and this is Stefan Reich of my group to show you what the quick models of life good morning everybody would like to show you how to create quick models and how to work with the class diagrams and vanilla so as Chris mentioned you can cat you can create quick models from individual files from groups from frameworks and even from targets and so let's plan and create a quick model from the sauce group do you see this handy design menu class model and we go to quick model and here we are for those of you who know UML you will notice that this is the Senate um out to notation we have different colors for the different objects which means classes are in bloom protocols or interfaces depending on the on the language here actually using or modeling are in red and then finally categories are displayed in the green so it's easy to distinguish the different types in the credit overview of of your structure of the project you see that inheritance is modeled or is displayed with a solid arrow whereas the the implement relationship is modeled with the dotted line so this means derived class for example implements derive protocol and derived protocol in turn extends base protocol the the initial diagram that comes up is very well it doesn't contain much detail is on purpose because it gives you a quick overview of of the product and so what you do is you can select individual operations to show properties or if you want to show more you select them all and bring up the context menu the context menu contains all of the items that Chris already mentioned alignment many of the graphic functions locking unlocking and then working with the weather compartment so we're going to expand the compartments here and you see this looks a little bit nursing so we just trigger they lay outside with them again and the blade out of correctly and so this is this is a good way of exploring unknown projects or getting an overview of code that somebody else wrote and so on you can also see that it is easy to hand optimize the delay out its diagram if you if you if you think that the layout I wouldn't did a bad job or it just is not is not very easy to understand you know you can just do it yourself and so of course the big question is what happens to the diagram when you change the code let's have a look at what happens and so we're looking at the base football here not there and for everybody to see we'll zoom in on it you see there's two methods defined and on the right-hand side here's the source code so we just emulate deleting a method by commenting it out and you see that the diagrams are actually interested I thought the same thing happens when you add a new method yeah so this is this is how you work with the class diagrams and how to play a quick models thanks Ivana i love this tool it is clear it's instant it's really responsive and i've used it to figure out what the heck Stefan and Miguel had been writing if I open try to look at the underlying framework save built to make this all work the first thing I did was well I used the modeling tool to model the modeling tool framework so I can figure it out it was really terrific so the quick models I think are going to be the one to use all the time just to pick a group pick a target pick a framework model it figure out what's going on what's related to what and navigate but if you want to if you've got a lot of people working on a project or if you're going to be spending a lot of time in one part of the code you can build your own navigation front end to that code with the tools that Stefan described and you can persist those you can save those with the project in a user model you define the content and the layout the positioning the directional arrows run the colors of the bubbles what's expanded what's not expanded things like that you can focus on a subset of code by picking either specific source files or groups of source files to model and you can not only track the changes in the files you're modeling but if you model at a group level you can track changes in that group so that if new classes or new files are added to that group they're automatically added to the model it's very cool and then once again these changes are stored with the project so that any changes you make the if somebody checks it out from the repository they go to your model they can see how you've arranged things how you've laid them out so let's go back to demo one and should have on can show you use models ok so here the user motive we create use a motor to little bit different events and quick ones because I you know one clip okay here we go so user models are created a little bit differently because we hook them up in the new file assistant and you see the design option here and we chose class model and renamed really a static user model and so this is the the core of creating user models on the left hand side you see beta TV the option of what kind of model you create it's either static or a tracking model this create we choose the static model and for now we create the static model based on the source code again which will pick up all of the source files so we click add and you see that out of the source files that are contained in the sauce group are actually added and we hit finish and here they are so we little bit larger view of this this is actually a mixed language project it contains both the seat ourselves and objective-c files and well this is this is how the general use them what it looks like so the important thing is once you create a user model it stays the same way regardless of if you change the source code or if you add new classes to the group or if you even add new classes to the source files that you created the model from so it's a little bit like a like a snapshot it's very handy if you want to document the evolution in your project for example now let's have a look at how the tracking models work because they are very different so we create in the same way and choose tracking now one of the difference with with tracking models is that they are mostly based on a group and so the idea is that you organize your code depending on your internal structure you organize them in groups so that they make actually send to you so that it's easy for you to understand certain components of your application and so we will model this by in this case of using the offline sauces group which model to separate aspect of this application and you see on the right hand side you don't see individual files but you see selected groups so in this case there's only one one file and two classes in the offline process group and so what happens if you rearrange your code or if you add new classes to the to the group that you're modeling is this let me into separate model here to the right and so I move these two files in this group and you see they're added automatically to your model so it becomes very easy to track to check to drag the groups that define a specific sub component of your application and obviously if I drag them out they will disappear as well now if if I add if I would add one class additional class here it will also show up in the diagram as well so you get 52 things for free adding rearranging your code will update the model I mean we arranging the files in the group in class we will update your model but also adding new classes new categories new interfaces and existing classes will also show up in the model that's it so far thank you thank you funny I think class modeling is going to be great help to you in your everyday work with Xcode it's going to give you a bird's eye view of your project so you can figure out what's going on in a big lump of source code it will help you make custom diagrams to communicate the architecture of the function of your code to other people on your team and it'll help you learn about third-party frameworks or Apple frameworks just by picking the Apple framework and getting an overview there are some limitations in the version that you have in your on your tiger disk with Xcode 2 point 0 1 the key thing to remember is that the class diagramming works off of the project index if you have turned off code since if you've turned off indexing you will not get class diagrams if the index hasn't completed you won't get class diagrams or you will get a partial class diagram to the degree that the index is completed so make sure that your index is complete before trying to build class diagrams and if you've structured your project in a way that exploits some of the shortcomings in the indexer for example you're including header files that have C++ classes but they're included from a dot C file the indexer will think well that header must be a sea header and so it can't possibly contain index files if your classes don't show up in your project symbols smart group they won't show up in the class diagram so if things are missing from your class diagram file bugs we know about them we will fix them by the time the ship's so let's talk about core data models now how many people went to the introduction or advanced core data sessions yesterday you've all seen this demo great okay so we will go a little more in-depth than what Andre I showed in those but you you've probably seen this two or three times by now core data models are kind of like class user models but they model data objects in a persistent store rather than modeling classes in your source code instead of inheritance relationships they have two one and too many relationships like you'd find in a database or in an XML data store file rather than in the the structure of an object-oriented piece of code just to recap what coordinate is about I probably don't need to tell you this again but its objects graph management for document based applications it'll manage your object lifecycle it manages undo redo it manages validation and relations between data objects and it persists a graph of objects either to a binary archive store to an XML format or to a sequel light database and it's driven by schemas and that's why we have this design tool because we need a good way for you to create those schemas instead of having to write a hunk of XML or to write a lot of code to create the schema schema is a model of your persistent storage what objects are in your store and how they relate to each other structured by the relationships the containment relationships between the objects rather than by the class relationships in your source code and it's keyed to your applications classes but you can of course have objects that aren't backed up by application classes butter instead interpreted by by other pieces of source code the entities in a data model are like classes in the class model attributes in a data model are like class variables relationships are like inheritance for category or protocol or whatever and there's this new thing called a fetch spec which is essentially a database query you make a schema in one of three ways you can derive it from an XML now you may I've gotten this question several times this week I have tried to feed xml into the importer in the design tool and it crashes or it breaks or doesn't work well you're trying to feed it somebody else's XML not ours right now the only XML we import is the XML we've exported because it's tagged correctly to create a schema we'll look at extending that in the future and doing more generic job of looking at an XML schema or a DTD or something like that but right now when you read in the XML it's only the special XML that we ourselves have created on exporting it okay you can however derive it from your application sources if you have an objective-c application with a bunch of classes that represent your data model you can take those classes and bring them right into the data model and create a data model from them that's probably the most useful thing if you've got an existing application or if you're writing an application from scratch and you want to start with the data model and then build the classes up from there you can start with a blank diagram and then create the model from scratch if you create it from scratch then you can just create new entities in the diagram with new entity from the design menu and then you enter the attributes new enter the relationships and it's right there in your model then you can back it up with code if you start with an existing data or schema you import it from the XML once again it's the XML we export and if you create it from code then you just specify the code files to model just like you specified the code models to create a class ma the code files to create a class class model from that classes are mapped into entities in the model the instance variables become attributes and the pointers to other classes in that model become the relationships once you've created a model you can change the attributes you can change the classes you can set values on them you can do a lot more than just use it for navigation so we've added a data model browser that lets you look at your objects your entities in tabular view and actually go in and inspect and change their values and there's a detail editor that lets you set the values on those entities in a very detailed way on very powerful way and here to demonstrate that is in Miguel Sanchez you guys hear me so my name is Miguel Sanchez and I'm here to walk you through the creation of a data model based on reverse engineering code I would focus so much on what we do with the code for that I asked you reviewed the advanced core data session that we did yesterday because this is a tool session I'm going to go more into detail as to what is really going on at the tool level and behind the scenes so what we have here is classes that represent a very simple mail system we have things like account headers mailbox messages we want to create the data model that represents the entities for these classes so as we've seen before data models are just another type of file type so we can do add new file you will see a new file size called data model it's called is my model and this is where I'm going to slow down a little bit we have an assistant that allows you to reverse-engineer your code for for data models if you wanted an empty data model you would just click finish without selecting any classes and that's how you get there there is no Neal empty model option anywhere so you just click finish what we see here on the left-hand side is your groups and fios tree that you have in your xcode window behind this assistant so here we have old HS MMG confining your project as I select a group for example in this case I'm going to sect select my data classes group we get in the second table view the list of classes that are containing this files in caso an important thing is happening here we're using the indexer to figure out what classes really are contained inside does HSN does that am so if you happen to try this at home and you see a little spinning wheel right about here I believe that's because the indexing is not yet done so it's not that the assistant is broken or anything just wait for the indexing to be done and then that's how we can figure out the information so we select a group we get classes we add all of the classes because that's that's what we want the model to contain and we click finish so here's the reverse engineer model when we hide in the detail area there for our classes now the lines are not inheritance unlike the class demo you just saw I'll talk a little bit more about that so what what it was reversing hearing what happened here for each class that we found in your files we obviously created an entity so we have the person entity for the person for class a message your code contains ivars so we try to be smart and for each I've are we we find in your code we create an attribute inside you're inside your entities now there's a little more going on there we don't just blindly copy attribute names to to entity attribute i'm sorry i VAR attribute names to enter together is because you might have underscore attributes that you don't really want persistent so we try to be a little smart and what really happens is though we go through your attribute list and we see if you can find if we can find setters and getters for those attributes and weak and if we do we assume that those are attributes that you want that are part of your data model and those are the ones that show up and they're given the right type if we can if we can figure it out otherwise we set them to be the unknown type is there some special class that you're using now where does the lines come from some some classes for example receiver here we'll have issues variables that point to other classes for example message and address if we determine the reverse engineering that the classes that these things going to are also in the set of classes that your reverse engineering we assume that you want those two entities related via to one relationship so those that's those were the lines that's where the lines come from we also detect inheritance I don't have it in this particular example but if you have an inheritance relationship between classes and both of those classes are being reversed engineer you will see the inheritance line so the inheritance line looks a little bit like this except that it's an open hero so that's what's going on with their reverse engineering process now let's bring up the browser view to get a little more detail into the editing of the model a browser view contains the same information that you see into your diagram is just in the tabular form let me hide this detail area first I'm going to talk about it later so what you have here is a very simple master-detail relationship you have the list of entities that you have in your model and for each entity we display the properties that are contained inside that entity so as I select an entity here I'm going to get a different set of properties for each one other of the entities now properties can either be attributes or relationships let's look at the more complex entity we have here for example message where it's message here we can sort on this message so here are the combined properties for message we can sort by kind we have attributes and relationships so properties can either be attributes or relationships but you might want to structurally they're different things attributes have certain fields that you can access a relationships has certain things you can do with them so here we're showing you things as properties combined so we have a minimum set of common fields for them but if you if you click on this corner area right here you can choose to see only the attributes or only relationships or fetch request which we don't reverse engineer right now but we have attributes so it's not just a filtering mechanism we're actually changing notice that we changed in the available columns that you have for you because structurally there are different things now speaking of columns you don't start out seeing everything that you have available for simplicity reasons we don't want to confuse you but there's a lot more stuff in there so for example here in the entities table view we're only showing you showing you the name of the entity if you option click I'm sorry control click on the on the column name you get to see all the other columns and you can add whether it be into this abstract a class that in maps to i'm going to add all of them in this case so that's how you add remember these if you don't see the columns you might expect to see they're just just add them so let's go back to message you can see attributes what kind of columns do I have available for my attributes well the attribute to type whether it's optional not transient minimum value maximum value all of them and for relationships we have the destination the inverse relationship min count max down to kill all of them now the columns inside the table views here are editable so for example for relationship here here's the relationship to address relationship to mailbox I can change the destination by just selecting the appropriate the appropriate entity here and so if you have you have a Deverell did all the content is editable or both in the table views and in the diagram view now let's go to the detail the detail editor which are hit before let me bring it up again so here this is another area where you can edit your information it behaves in there in a particular way because you can have two kinds of details right you can have the detail for the entity if you're clicking here so if I click on an entity you'll notice that this little easier highlights and the fields that you see over here correspond to the entity so it's the entity name the class apparent if I click let me go back to through a class that has a lot of properties if I click on a property the little pea here highlights and the end the detail here being shown is is the detail for the property and editing so I can be editing and property and then and then want to go back to the entity that it belongs to and edit the entity property or GoPro the entity detail or go back to the property detail and of course if you select the relationship that property looks that the detail looks different now you might you might ask why do I want an extra editable area here if I can do a lot of the stuff in the diagram view or in the diary or right here writing the tables well this comes in handy for multiple selection let's say I select all of my entities and I look at all the properties inside all of those entities so now this middle area here is showing me the list of all the available properties in all the proper and all the entities I selected you'll notice that we added a column here entity automatically when we detected multiple selection so that you know which property you're dealing with which entity you're dealing with now let's look at properties as attributes and let's sort by type and let's look at all the attributes that were reversed engineered to be integers 32 if I multiple select these I can set all of them to be integer 64th in one in one stroke looking so that that's the motivation of this detail area that's and and we're still no I think I think that most most apply I think we got everything that all of the fields in here in the table view in an edible form let's see one last thing about the detail area so you have the entities area of the properties these two icons here the one on the Left shows you the detail which I've been talking about it all this time the I stands for user info dictionary now entities and properties and properties whether they be attributes or relationships and contain a user info dictionary this is just an area where you can add your own keys and values for however you want to use them in your in your in your code so if you look at the API for NS attribute inscription in this entity's description you'll see you can get to and instead a dictionary so this is where you will be saving the dictionary and it's the same thing for no matter what I feel like so i can select the property or i can select an entity you stirring for dictionaries just a user in for dictionary so don't be confused by this fields remember what what part you want to edit I select an entity worse its detail well let's look at the general fields for that entity or they or the user and the dictionary the last thing the last kind of property I want to talk about are these things called such requests let's go the message and look at properties so think of which requests as a pre-built query into your data set so I want to get all the messages that meet a certain criteria now to build the query you need a boolean editor so let's add a fetch request hear my request okay so we have something called a predicate builder a predator builder is a graphical boolean equation editor so you can add knowns and combine them with ands and ORS and I'm not going to go into detail of creating a sophisticated at a boolean expression here but basically this is where you would define criteria that you will eventually use the runtime to fetch your data set now the boolean equation is simply made up by key value comparisons the keys come from the entities that you're selected and depending on the kind of key you're selecting you have a set of values that you can query on you can set you can pour your own dates or non a boolean value on strings and numbers so this is a pretty nifty graphical editor and you're able to go into to do things like dragging notes between different places so so that's a lot you can do with this error again oh ok I think I think that covers the the highlights of the of the data model ending or 11 lesson and dress wanted me to show you here you saw that Andrea Kazan you just peruse them will kept opening these things up now this is your same document now right the data is now your model you're used to opening multiple windows of your text information and as you type things in one area you obviously see them updated in the other area so the model information is your model is the data so if you move the if you move things around they're moved in the other in the other editor okay so that's the whole thing is your model including including the browser area so for the for the next demo after a few more slides from Chris we're going to go we're going to build an actually running application but that's that different this time thanks for you so you've seen two ways in which the data models are different from the class models first that they model the data elements and are heavily editable so that you can go in and change things and set settings on them there's another way in which they're different in that data models are essentially source files in your project and they are built into object files using the standard Xcode build system this is important not just for data models for core data framework but for other framework for other models will add in the future where you need to model something run it through a process at Build time and create an artifact a compiled thing that you deliver with your application for other data-driven frameworks for example well just say Koko scripting comes to mind so we have built that structure into the plug-in architecture of the design tools so the dinning design tool can have a built-in compiler or have a compiler spec that run some other process on the system to process its model at Build time and create something in your deployed executable so in just the same way that a see file is transformed into a dot o file it's built I'm a model file is transformed into in this case a dot mom file a managed object model schema file and when you build a core data application they just like your object code is combined into an executable that's in the mac OS folder in your in your bundle the mom file is tossed into the resource file and it's just built there by the standard xcode build rules so Miguel is going to show you how to build a core data application and how the pieces go together 196 me again so now we're going to build a functioning core data application you've seen this again in the Indian core data sessions before early in the week where we're going to go through it again you know a lot more detail as to what's really happening at the tool level so I'm going to create a new project you'll notice that there's two new templates there are now goes to the pre-existing cocoa templates that we have we've always had so we have now a core data application template and the core data document based application template I'm going to create one of these colored demo what's new in this templates what do you get well you get three three big things the first is that you're automatically linked against the core data framework obviously because you'll be using it you get a slight change in your document class so let me fix the font here there's some there's a problem with the tree view I have to reset the font for it to read wrong okay that's better so we're we're linked against the core data framework first difference second difference we give you a document file just like we give you in the other template except that this document file inherits from this new class call and it's persistent document I'm not going to go into the details of the class you want to show you the difference and the third difference with this template is that we give you a blank model where you'll be putting your entities either by reverse engineering or creating new entities but we're going to do everything from scratch here let's bring up the browser area I'm going to create a very simple model that has two entities and a person entity and an address entity and they'll be related so let's create two entities I'm also showing you the editing features here and so the first entity elated here in the table view it's called person the second entity will edit in the diagram view is called address let's add to two attributes to the entity to the person entity so let me expand all of my compartments here where they died we have the same mechanisms that you sauce to find demo in the class diagram so we can expand all so we're in person this one this will have a field called first name and this will have a field called last name oops they just write the whole thing backwards there and then we go to address we are another field this will be the street and it's not optional because it's the only field we have in there now here's what multiple selection comes in handy i can select all of my oh my entities i just added three fields and I want the multiple strings so they all become strings now let's add a relationship between these two entities so we select person we click on this little plus are here we now have a relationship the relationship will be called the main address of the person the destination will obviously be the address entity you get the line and it's a one-to-one relationship and that and that's about all I'm going to do with the relationship right now so let's look at the nibs that we got doesn't have much it's empty let's create a simple UI for this for this model so all I'm going to do is I'm going to option drag person into the NIP file and I'm going to drop it there and interface builder comes up and says you want a UI that handles many objects or one object so I want to either handles many objects so there's the UI no thank you we've only shown you this three times before but thanks for clapping so what happened here for it for each end for each app for the person we gave you a table view where you can see multiple multiple people that's the kind of UI h owes to create where the columns come from I got a column for each one of the attributes i have in my person and of course a detail selection area here for to editor whatever i have selected in my in my table view here add remove buttons so this is the same thing for the notice that because we have a relationship i don't think we had shown you this in the other demo i don't remember the relationship part we have the main address as a pop up here so we need a UI to enter addresses too so let's go here click on address also drag it there yeah I want the same thing there's the UI and let's just put it there ok so the same thing happened we got a multiple you i4ii editing multiple addresses the street so let's quit interface builder get back to our model okay so here's where some new stuff happens I'm going to build what is happening when we're building we're compiling obviously your source code you're all familiar with that we're also compiling this we're also compiling the data model I don't think we have mentioned that in any in any other session if you go into your target area here and you look at your sources you'll notice that as a source you have your dot M but now you have this new type of file which are your actual model files now what does it mean to compile a model file well let's look at it and see what's watching it let's reveal this model file in the finder so this is these are your project classes this is a the model file your editing let's look at it you shouldn't do this in home because it's private but well I'll chose here here so what you'll see inside that model file are the internal files we use in the tool to keep track of what you're editing so we have an archived version of your elements and delay out and all this extra private secret stuff that we have to make it to make the editing experience nice for you but the runtime doesn't need this thing that the runtime is simply interested in the structural information of your entities so that is what compiling means compiling means translating this data model file into a highly optimized runtime version of the file and the extension of that compiled version is what we've been calling the dot mom file so if we go if we look into the build output here here's my compiled application let's go look into it inside the content you'll see that in the Resources directory you will have a file that has the same name as the model you were creating in your in the tool but it has the extension that mom so this is the file that the framework loads at runtime it's found in the in the resources directory and if you have multiple files we load all of them and we combine them and we get all of the entities okay so I wanted to explain this in a lot more detail because it gets how many people have used the old deal modeler and ldos okay so the main difference here is that the tool model and the runtime model are different things it used to be the same file in the past so now let's run the application so here's our UI when I did the Dragon interface builder all of the bindings were set for me and everything works it's it might seem like magic but it's all there for you which is we just do the work for you that we don't really hide anything you can always go into the move and change things so i can add we've demoed this before so I'm just going to go and quickly and here i can add myself i need to have an address so i add an address i live in one main street you'll notice that the moment i add an address it shows up in the pop up here because this is all being handled by the core data frame work so i have my address and i'm going to save it what i want to show you is what happens when we say so i'm going to save an xml format my doc let's go my data we save will quick the application i'm not what i want to show you is where the saving what happened when to safe so where did I put it I didn't put it owww thank you because one so here's our xml file what i wanted to show you was what what's inside it so let's open it and all right that's a different one in my data one everything was going so well okay so that's the XML it's a human readable representation of your file you have a little structural information is that the last name first name and the actual content now why did I show you this file size so you have the three files right you have defiled your editing the tool the thing is compiled to a dud mom and where the data is actually stored I just wanted to briefly mention something highlight something that Chris has mentioned you think that in other sessions we do this thing called with this we use this import function right what does importing do importing now that you know what all of the files are about if you if you want to experiment the input with the import function the only things that you can import are the dot mom file or the xml files okay because they don't have any visual information they're kind of optimized or compiled versions of your data but if you want to kind of reverse engineer the entities are inside those files you can always import them back in put them back in and you need to import into a blank file so you first need to create the model and then do the important that's that was the secret that we've been using for the last two days or three days in your demos the important functionality and that's it for this time great thanks if you want to see more of how that magic worked we'll all be in the Xcode lab at end of the hall on the left after this session so you can come play with the tool will show you how to use it most of the stuff that you've seen here you can do at home we've made some changes in the version that we're using here at the show but you've got pretty much everything you need to recreate these demos on your tiger preview disk and with Xcode two point oh so you can try this at home data modeling as you can see really helps you build and navigate your schemas graphically create models directly from code or from XML that we've exported and to build your entire core data application in the Xcode tool without having to go out to separate tools I think you'll find that the integration of the design tool into your workflow is really going to significantly help and accelerate your experience in building core data applications so I've given you a taste of the two main plugins that you get with Xcode 2 point 0 as you can see we put in a pretty big architecture the diagramming architecture the modeling architecture the building architecture to make it possible for us to extend the design tools over time Matt Formica is here and so I'm going to give the obligatory Mac Formica we're not talking about anything beyond tiger at this point explanation but I want to give you some idea of where we think it's going just so we don't have to listen to you come up to the mic and say you know it would be a great idea if you and then we'd say thank you for the feedback which will happen anyway there are a lot of data driven frameworks in Mac OS 10 and it would make sense to model these things with a modeling tool rather than having you write xml files or configuration files doing your Apple script ability for your cocoa application in a model would make a lot more sense we wanted a modeling tool / script ability for a long time we think that we can move this in that direction the preferences the ice Inc kit those are all great candidates for having modeling tools added and we're looking at those and even looking at your interface builder nib file as a diagram of the objects rather than as things on the screen see there's demand for that just what we want we're also going to improve the plugins we've got and extend the class modeling the primary thing that we know you're going to ask for because it's kind of obvious and we do it in interface builder and other tools do it is well if I can do detailed editing of the data model with that browser well why don't you have one of those so I can do it in the class model as well so I can actually change my source code or even create new classes right in the diagram and have the source files created it is harder than it sounds it's easier than it looks we will go in that direction and give it a try but the main thing we want to do code my code creation partisans over there that's great the main thing we want to do though is we want to along with the rest of the Xcode plugins open this plug-in API so you can create your own design plugins so if you have your own data driven framework or you have your own direction that we are laggards in going in you can add that to yourself and we're working in that direction as well so in summary design and modeling is now an integral part of Xcode it's not a bag hanging off the side it's not a separate tool you have to launch it's part of your workflow it works the way you do rather than having a design and modeling tool impose the workflow on you you can integrate in to whatever workflow you like you can choose whichever one of the xcode multi window or single window layouts you'd prefer to use the design tools work just like documents in those workflows it's a versatile diagramming view you've seen it already applied to two very different kinds of models we expect to be able to apply it to different kinds of models in the future the core data it's built into the build system so that it works for models that create artifact files that are loaded by data-driven frameworks Maps something we can extend in the future the class models I think are very versatile and useful right now for letting you analyze letting you explore and letting you communicate what your classes do in your application and it's an extensible architecture so we have a lot of room for growth in the future Matt Formica is our tools evangelist he's the key contact all feedback should go to the Xcode feedback group once this tools released the standard Xcode discussion groups will apply but this is an Xcode 2.0 only it is covered under the non-disclosure so send us feedback on xcode ash feedback at groups at apple com
