Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > iPhone, iPod and iPad > iPad

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 11, 2013, 04:16 PM   #1
jsanto
macrumors newbie
 
Join Date: Jan 2013
Multiple predicates in various tableviews

I just canīt stop searching and reading about the "changing of the predicates" but i still donīt know how to resolve my problem, so...what i have is:

1 - Several tableviews with various cells and each cell has multiple textfields.

2 - The user presses one of these textfields and a tableview(inside a popover) appears.

3 - this popoverTableview has all the core data "work" and it is suppose to provide data to insert in the pressed textfields.

4 - Everything works fine...EXCEPT the fact that i need the predicate to change every time the user passes for example from tableview1 to tableview2.

5 - Below is my NSFetchedResultsController method that is inside my popoverTableview and i have tried numerous approaches like: "ifīs" ; "switches" ; also point to the textfield tag in the tableviews and nothing. I think i donīt need to set the cache to nil since it is already set to nil...also tried deleting the: if (_fetchedResultsController != nil) return _fetchedResultsController;

And nothing!!!, what do i need to understand? What iīm not getting? iīm losing days on this one.HELP!

- (NSFetchedResultsController *)fetchedResultsController
{
if (_fetchedResultsController != nil)
{
return _fetchedResultsController;
}

NSFetchRequest *fetchRequestList = [[NSFetchRequest alloc] init];
NSEntityDescription *entityList = [NSEntityDescription entityForName:@"List" inManagedObjectContext:self.managedObjectContext];
[fetchRequestLista setEntity:entityList];

TableViewOne *table1 = [[Cobertura alloc]init];
TableViewTwo *table2 = [[Cobertura alloc]init];

if (table1 textFieldShouldBeginEditing:table1.textFieldPressed)
{
fetchRequestList.predicate = [NSPredicate predicateWithFormat:@"%K IN %@", @"reference", arrayTableview1];
}

if (table2 textFieldShouldBeginEditing:table2.textFieldPressed)
{
fetchRequestList.predicate = [NSPredicate predicateWithFormat:@"%K IN %@", @"reference", arrayTableview2];
}

NSSortDescriptor *cellTitle = [[NSSortDescriptor alloc] initWithKey:@"reference" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:cellTitle, nil];
[fetchRequestLista setSortDescriptors:sortDescriptors];

_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequestLista managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"referencia" cacheName:nil];
_fetchedResultsController.delegate = self;
self.fetchedResultsController = _fetchedResultsController;

return _fetchedResultsController;
}

Thanks in advance
jsanto is offline   0 Reply With Quote

Reply
MacRumors Forums > iPhone, iPod and iPad > iPad

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Another multiple ID, multiple device, multiple phone number iMessage question mrcalabash iOS 6 3 Jan 12, 2013 07:45 PM
font in tableviews LARRYSE iPhone/iPad Programming 6 Nov 13, 2012 08:27 AM
Difference between a cell and a row in Tableviews? animefx iPhone/iPad Programming 4 Aug 7, 2012 02:35 PM
Core Data Predicates nashyo iPhone/iPad Programming 0 Jul 11, 2012 12:09 PM
Two TableViews in a single ViewController ?? Fritzables iPhone/iPad Programming 2 Jul 8, 2012 07:25 PM

Forum Jump

All times are GMT -5. The time now is 08:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC