core data - Displaying count of the value of a to-many relationship in an iPhone app -


I need help with a few things

I use core data to do this

I have the main table view where the categories are stored I when one of the categories is pressed, another table view is pushed and the contents of that particular categories are displayed. There is one-to-many relationships between category and content

I want to display the total number of categories for each of the categories. I manage to do this for a single category by inserting this code after fetchrequest in the content table view controller:

  NSUserDefaults * defaults = [NSUserDefaults StandardUserDefaults]; NSString * Number String = [NSString stringWithFormat: @ "% i", [contentArray count]]; [Default set object: number string fork: kContentNumber];  

And then in the View View Controller, I simply loads the number from NSUserDefault, and it displays in TableView. Of course, the numbers for all the lines of the series have become the same.

My challenge is to get a specific number from each content, and display it in the respective category.

Any help would be highly appreciated in advance thanks

It seems that You have a category unit in which there are many relationships with the content unit.

If so, you can only count your content from the UTT VUI Controller of the content class:

categories.contents count]

example title:

  #import & lt; CoreData / Cordaita H & gt; @ Class content; @ Inter Category: NSManagedObject {} @property (nonatomic, retain) NSSet * content; @end @ Interface Category (CoreData GeneratedAvarres) - (Zero) addContentsObject: (content *) value; - (zero) extracting system object: (content *) value; - (zero) add content: (nsat *) value; - (zero) Remove resource: (NSSet *) value; @end  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -