cocoa touch - Core Data NSFetchedResultsController code shortenning -


Then the core is quite new in the data and you have decided to use the magic record to reduce the LOC.

My first scene is, I have a list of companies and each company has N sum of users

Currently, it was all successful, but My code is ridiculously long.

What I have to do is to reduce the code, because I know how I can do it, I am not sure how.

If you see the code below, you'll see a common line when calling NSFetchedResultsController

  [self.fetchedResultsController.sections [0] objects] < / Code> 

Is there a way to reduce it, so I have to use index of NSFRC?

  self.fetchedResultsController = [self.fetchedResultsController.sections [0] objects]  

Thanks for your time

Update: I think I can only get an array from the controller of the results obtained and use it?

  NSArray * Companies = [NSArray arrayWithArray: [self.fetchedResultsController.sections [0]]] Objects; Will my objects still maintain the same memory address?  
  #pragma mark Fetched Results Controller - (NSFetchedResultsController *) fetchedResultsController {// Fekshed set up results controller if necessary if (_fetchedResultsController == null) {self.fetchedResultsController = [company MR_fetchAllSortedBy: Do not climb: proof with yes: by zero group: zero representative: self-reference: self.managedObjectContext]; } Return _Feded Results Controller; } #pragma Icon - View table data source - (NSInteger) numberOfSectionsInTableView: (UITableView *) table view {return [[self.fetchedResultsController.sections [0] objects] counting]; } - (NSString *) Talikadrishy: (UITableView *) Table View Title ForHeaderInSection: (NSInteger) section {NSString * string = [[[self.fetchedResultsController.sections [0] items] objectAtIndex: section] title]; Return string; } - (NSInteger) Table Views: (UITableView *) Table View Snkyaofrejh Insashn: (NSInteger) section {return [[[[[self.fetchedResultsController.sections [0] items] objectAtIndex: section] Users] all objects] count]; } - (UITableViewCell *) Talikadrishy: (UITableView *) Table View Selforaatindpath: (NSIndexPath *) Anukrmnikapath {static NSString * cellIdentifier = @ "cell_identifier"; [TableView registerClass: [UITableViewCell class] forCellReuseIdentifier: cellIdentifier]; Table view cell * cell = [[table view cl alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: cellIdentifier]; UserProfile * user = [[[[[self Reset Results Controller Section [Object] ObjectAutandx: IndexPath.section] Users] All Objects] ObjectAntindex: IndexPath.ro]; Cell.textLabel.text = user.title; Cell.detailTextLabel.text = user.email; Return cell; }  

I think that if you just use

  - [Self-targeted items: endindexpath: indexpath]  

There will be a major reduction in the data access code you already have.

Also, to do this:

  [tableView registerClass: [UITableViewCell class] forCellReuseIdentifier: cellIdentifier];  

In your table view: cellForRowAtIndexPath: method generally, deodeload to see it: or some other initialization method.

And, I personally use - [NSARRA Ultimate Object] or - [NSARRA First Object] methods.

Instead of crashing due to an array index, these methods will return to zero.

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -