Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:04:25+00:00 2026-05-18T21:04:25+00:00

Please help me to fix this issue (Im getting crazy now!), My project is

  • 0

Please help me to fix this issue (Im getting crazy now!), My project is saving the data properly to the sqlite db in coredata, as checked in a SQLite grapical manager,but I dont seem to be able to show it in a table view, I need my table inside my viewController (small table not whole screen),

If you feel generous please check my little sample project
Here Thankyou!

here the code of the *viewcontroller.h

(Please note that I included a IBoutlet for the table view as tableView is not an instance in UIViewController!) was this done properly?,
also, I get 7 warnings where i call the tableView> Local declaration of ‘tableView’ hides instance variable

#import <UIKit/UIKit.h>


@interface CoreDataEnsaViewController : UIViewController 
<UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate> //va     controller delegate??


{

UITextField *name;
UITextField *address;
UITextField *phone;
UILabel         *status;


//la table
//NSMutableArray *array;

//la tabla??
UITableView *tableView;
NSFetchedResultsController *_fetchedResultsController;
NSManagedObjectContext *_context;  
}

@property (nonatomic, retain) IBOutlet UITextField *name;
@property (nonatomic, retain) IBOutlet UITextField *address;
@property (nonatomic, retain) IBOutlet UITextField *phone;
@property (nonatomic, retain) IBOutlet UILabel *status;

@property (nonatomic, retain) IBOutlet UITableView *tableView;

@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSManagedObjectContext *context;

- (IBAction) saveData;
- (IBAction) findContact;
- (IBAction) showbtn:(id) sender;

@end

and here the *viewController.m

#import "CoreDataEnsaViewController.h"
#import "CoreDataEnsaAppDelegate.h"
#import "ShowViewController.h"

#import "Contacts.h"

@implementation CoreDataEnsaViewController

ShowViewController *showView;

@synthesize name, address, phone, status, tableView;

@synthesize context = _context;
@synthesize fetchedResultsController = _fetchedResultsController;

-(IBAction) showbtn:(id) sender {

showView = [[ShowViewController alloc] initWithNibName:@"ShowViewController"  bundle:nil];

//anima
[UIView beginAnimations:@"flipping view" context:nil];
   [UIView setAnimationDuration:1];
   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
                       forView:self.view cache:YES];

[self.view addSubview:showView.view];
[UIView commitAnimations];  

}

  - (void) saveData
 {
CoreDataEnsaAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

NSManagedObjectContext *context = [appDelegate managedObjectContext];

NSManagedObject *newContact;

newContact = [NSEntityDescription insertNewObjectForEntityForName:@"Contacts"  inManagedObjectContext:context];

[newContact setValue:name.text forKey:@"name"];
[newContact setValue:address.text forKey:@"address"];
[newContact setValue:phone.text forKey:@"phone"];

name.text = @"";
address.text = @"";
phone.text = @"";

NSError *error;
[context save:&error];
status.text = @"Contact saved";
    }

    - (void) findContact
   {
CoreDataEnsaAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

NSManagedObjectContext *context = [appDelegate managedObjectContext];

NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Contacts" inManagedObjectContext:context];

NSFetchRequest *request = [[NSFetchRequest alloc] init];

[request setEntity:entityDesc];

NSPredicate *pred = [NSPredicate predicateWithFormat:@"(name = %@)", name.text];

[request setPredicate:pred];

NSManagedObject *matches = nil;
NSError *error;

NSArray *objects = [context executeFetchRequest:request error:&error];

if ([objects count] == 0) {
    status.text = @"No matches";
} else {
    matches = [objects objectAtIndex:0];
    address.text = [matches valueForKey:@"address"];
    phone.text = [matches valueForKey:@"phone"];
    status.text = [NSString stringWithFormat:@"%d matches found", [objects  count]];
}
[request release];
    }

- (NSFetchedResultsController *)fetchedResultsController {

if (_fetchedResultsController != nil) {
    return _fetchedResultsController;
}

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Contacts" inManagedObjectContext:_context];
[fetchRequest setEntity:entity];

//NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"details.closeDate"  ascending:NO];
//[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];

[fetchRequest setFetchBatchSize:20];

NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:_context sectionNameKeyPath:nil cacheName:@"Root"];
self.fetchedResultsController = theFetchedResultsController;
_fetchedResultsController.delegate = self;

[fetchRequest release];
[theFetchedResultsController release];

return _fetchedResultsController;    


}




// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];


}



- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}


- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}


- (void)viewDidUnload {
self.name = nil;
self.address = nil;
self.phone = nil;
self.status = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}



//tabla

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView

numberOfRowsInSection:(NSInteger)section {

 id <NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController  sections] objectAtIndex:section];
 return [sectionInfo numberOfObjects];

//return [array count];
//return [[fetchedResultsController sections] count];
  }


- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {

    Contacts *info = [_fetchedResultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = info.name;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@, %@", info.address, info.phone];

}


  //---insert individual row into the table view---

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:  (NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";
//---try to get a reusable cell---

UITableViewCell *cell = [tableView  dequeueReusableCellWithIdentifier:CellIdentifier];



//---create new cell if no reusable cell is available---

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


}


// Set up the cell...
[self configureCell:cell atIndexPath:indexPath];



return cell;

 } 



  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[tableView deselectRowAtIndexPath:indexPath animated:YES];



}

 //tabla end



 - (void)dealloc {
[name release];
[address release];
[phone release];
[status release];

self.fetchedResultsController = nil;
self.context = nil;

[super dealloc];
}


 #pragma mark NSFetchedResultsControllerDelegate methods

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    // The fetch controller is about to start sending change notifications,  so    prepare the table view for updates.
    [self.tableView beginUpdates];
}


- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {

    UITableView *tableView = self.tableView;

    switch(type) {

        case NSFetchedResultsChangeInsert:
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
            break;

        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            // Reloading the section inserts a new row and ensures that titles are updated appropriately.
            [tableView reloadSections:[NSIndexSet indexSetWithIndex:newIndexPath.section] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {

    switch(type) {

        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}


- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    // The fetch controller has sent all current change notifications, so tell the table view to process all updates.
    [self.tableView endUpdates];}



@end

The connections in the xib are>
table view
outlet:
data source———–files owner;
delegate————–files owner;
referencing outlets
tableView————-files owner;
thank you so much!!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:04:26+00:00Added an answer on May 18, 2026 at 9:04 pm

    Try to add this code to perform a fetch of data in your viewDidLoad method:

    NSError *error = nil;
    if (![[self fetchedResultsController] performFetch:&error]) {
        NSLog(@"Unsolved error: %@, %@", error, [error userInfo]);
        abort();
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create layout like this In the QT i created widgets
Server Error in '/' Application. -------------------------------------------------------------------------------- No parameterless constructor defined for this object. Description:
I have an event this._sequencer.Completed Two delegates are subscribed to this this._sequencer.Completed += OnActivityFinished;
So, I'm starting a C++ class right now, and I've configured NetBeans (which I
I am trying to get the thumbnail meta data for the posts in my
I am working on a sample to get the list of printer connected to
hi how to add widget inside widget i created main widget, and for the
I know its a not a new concept that my site is perfect on
When I try and define (but not implement an it test) (pending method) using
I have a range in excel named ValuesRange located at Cell B5. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.