Core-Data: NSLog output Does Not Show “Fields”?

To view the individual fields of the objects in the array you must reference them directly. You are using this to show the objects in the array: NSLog (@"Element %i = %@", i, stories objectAtIndex: i) NSLog generates a description of each object when you use %@, which is often convoluted or useless. If you want to see the fields inside try something like this: NSLog (@"Element %i contains fields: %d - %s - %d",i,stories objectAtIndex: I getIntegerField,stories objectAtIndex: I getStringField,stories objectAtIndex: I getAnotherIntegerField) The values displayed will be the values returned by the getter functions of each object you are referencing in stories.

To view the individual fields of the objects in the array you must reference them directly. You are using this to show the objects in the array: NSLog (@"Element %i = %@", i, stories objectAtIndex: i); NSLog generates a description of each object when you use %@, which is often convoluted or useless. If you want to see the fields inside try something like this: NSLog (@"Element %i contains fields: %d - %s - %d",i,stories objectAtIndex: I getIntegerField,stories objectAtIndex: I getStringField,stories objectAtIndex: I getAnotherIntegerField); The values displayed will be the values returned by the getter functions of each object you are referencing in stories.

Thanks for the response, could you please elaborate a bit more on the getIntegerField, getStringField. I get an error stating these methods are not found. Is this something I have to code?

– Stephen Jun 24 '10 at 14:03 Sorry, I should have been more specific. Those were supposed to be general getter methods as I am not very familiar with the NSManagedObject class. There should be some methods for retrieving the information stored in the NSManagedObject and interpreting it, then you can use the nested method format to output that information.

For example if you wanted to return the entity 'Tabrss' you would use stories objectAtIndex:i entity. I'm not quite sure what information was left out originally though. – NWilkie Jun 24 '10 at 14:50.

The output you are seeing is from the description method of the NSManagedObject class. It is just a human readable output intended for lightweight debugging purposes. You're not supposed to actually use it to parse or store data.

You don't see any detail about the data in the description dump because the managed objects were fetched as "faults" which means they are mere ghost of objects and contain no real data. To fetch the full fledged objects immediately, you would set you fetch request to do so with: request setReturnsObjectsAsFaults:NO; ... then when you log the objects you will see their data and relationships. To actually use the data in the attributes, you have to query the attributes directly using one of the value methods such as valueForKey:@"attributeName".

Edit: After editing your question, I think I need to elaborate. You're thinking about Core Data all wrong. Core Data is not a database.It does not have fields.

The return of a fetch request is not a table. The relational database elements in Core Data are utterly optional and hidden. Instead, Core Data is an object graph manager that maintains the integrity of relationships between objects.

The data is stored in objects and when you fetch from the persistent store you get back an object, not a field, column or row. In this case, the fetch is returning a generic NSManagedObject that is configured to represent an entity Tabrss in your entity graph. Each managed object instance represents one logical Tabrss object.

To get any value from from any Tabrss object you ask the managed object for the value associated with the name of the attribute of the Tabrss entity. Suppose your Tabrss entity has a name attribute.To get the name of every Tabrss in your fetch you would use: int i; for (i = 0; I Name); The important thing it to remember you are dealing with full fledged objects and not arrays, matrixes, tables or some other dumb data structure. You get the data from from each individual object by sending a message asking for the value of one its attributes.

Thanks for this post, I've just back round to reading it now. I managed to get this part of my project working. Also, thanks for the explanation about Core Data.

I'm very new to iPhone development, but have learned a lot over the last few months. I have a strong programming background so when I saw Core Data, I naturally started using terminology that I was familiar with. When my App is finished I plan to go back to the start and review everything.

Thanks again for the help. – Stephen Jul 9 '10 at 9:52 Yes, people with solid DB experience often have a harder time learning Core Data than novices. It's just natural to think about in terms of what you already know.

– TechZen Jul 9 '10 at 12:59.

The output you are seeing is from the description method of the NSManagedObject class. It is just a human readable output intended for lightweight debugging purposes. You're not supposed to actually use it to parse or store data.

You don't see any detail about the data in the description dump because the managed objects were fetched as "faults" which means they are mere ghost of objects and contain no real data. ... then when you log the objects you will see their data and relationships. To actually use the data in the attributes, you have to query the attributes directly using one of the value methods such as valueForKey:@"attributeName".

After editing your question, I think I need to elaborate. You're thinking about Core Data all wrong. Core Data is not a database.

It does not have fields. The return of a fetch request is not a table. The relational database elements in Core Data are utterly optional and hidden.

Instead, Core Data is an object graph manager that maintains the integrity of relationships between objects. The data is stored in objects and when you fetch from the persistent store you get back an object, not a field, column or row. In this case, the fetch is returning a generic NSManagedObject that is configured to represent an entity Tabrss in your entity graph.

Each managed object instance represents one logical Tabrss object.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions