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 6170859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:06:47+00:00 2026-05-23T23:06:47+00:00

Another newbie question, just when I thought I was beginning to get a very

  • 0

Another newbie question, just when I thought I was beginning to get a very
small handle on ios programming. Ugh! I’m following a tutoria from the
appcodeblog.com where I’m building a simple tab bar application utilizing
core data to enter, display, and search vacation destinations. I’ve worked
through the tutorial and have a working app, but I notice when I select the
“Show Destinations” tab I get the following error. The app seems to continue
working, but the error is logged to the console. I’m trying to debug the
issue and understand exactly what is happening, but I just don’t quite
understand what is wrong. I “think” I have an issue with my
ShowDestinations.xib file where I’ve incorrectly hooked up my objects within
the xib. Any help is MUCH appreciated. Thanks in advance for your help and
time.

Here’s the error, “CoreDataTabBarTutorial[1262:207] Failed to call designated
initializer on NSManagedObject class ‘Destination’.

I’m not sure what code to provide so I’ve started out by showing my header
and implementation files ShowDistinationsViewController.h and
ShowDestinationsViewController.m

ShowDistinationsViewController.h

#import <UIKit/UIKit.h>


@interface SearchDestinationsViewController : UIViewController {

    UISearchBar *destinationSearchBar;
    UITableView *searchTableView;

    NSFetchedResultsController *fetchedResultsController;
    NSManagedObjectContext *managedObjectContext;

    NSArray *fetchedObjects;

 }

@property (nonatomic, retain) IBOutlet UISearchBar *destinationSearchBar;
@property (nonatomic, retain) IBOutlet UITableView *searchTableView;

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

@end

ShowDestinationsViewController.m

#import "ShowDestinationsViewController.h"
#import "Destination.h"

@implementation ShowDestinationsViewController

@synthesize destinationsTableView;
@synthesize destinationsArray;
@synthesize fetchedResultsController;
@synthesize managedObjectContext;

// Not sure where the following code came from so I commented it out!!! It didn't seem to break anything when I commented it out
//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}

- (void)dealloc
{
    [destinationsArray release];
    [destinationsTableView release];
    [super dealloc];
}

- (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.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

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

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


#pragma mark -
#pragma Data Fetch from Core Data

- (void) viewWillAppear:(BOOL)animated
{

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Destination" inManagedObjectContext:managedObjectContext];
    [request setEntity:entity];
    NSError *error = nil;
    NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
    if (mutableFetchResults == nil)
    {
        // Handle the error.
        NSLog(@"mutableFetchResults == nil");
    }
    [self setDestinationsArray:mutableFetchResults];
    [request release];
    [destinationsTableView reloadData];
} 


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [destinationsArray count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    Destination *destination = [[Destination alloc] init];
    destination = (Destination *)[destinationsArray objectAtIndex:indexPath.row];
    cell.textLabel.text = destination.name;
    [destination release];

    return cell;
}

#pragma mark -
#pragma mark Table view delegate

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

}

@end
  • 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-23T23:06:48+00:00Added an answer on May 23, 2026 at 11:06 pm

    The problem seems to lie in

    Destination *destination = [[Destination alloc] init];
    destination = (Destination *)[destinationsArray objectAtIndex:indexPath.row];
    [destination release];
    

    The first line is unnecessary: In Objective-C, Destination* is a pointer to the object, not the real object. The Destination object you want is presumably already in the array. So you don’t have to create an object to point to, in the line [[Destination alloc] init], which is gone immediately at the next line. What’s going on was

    1. [[Destination alloc] init] creates an object a, destination points to a. a is retained by you.
    2. (Destination *)[destinationsArray objectAtIndex:indexPath.row] gives you another object b, which is not retained by you. destination now points to b. No one holds a any longer.
    3. release is sent to the object pointed to by destination, i.e., to b. This is against the retain-release rule; you should release a, not b!

    So, instead, just do

    Destination *destination = (Destination *)[destinationsArray objectAtIndex:indexPath.row];
    

    without the release part.

    As an advice: always run Analyze (which is available below the Build menu) when you build your project. The analyzer is designed to catch common types of errors, including yours. Correct your code so that all the analyzer warnings go away; you should always regard the analyzer warning as an error on your part.

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

Sidebar

Related Questions

Now following my series of python newbie questions and based on another question .
another iPhone newbie question... I have the following: NSPersistentStoreCoordinator NSManagedObjectContext NSManagedObjectModel Is it possible
Another newbie (Common) LISP question: Basically in most programming languages there's a mean for
Another newbie question from me. Just checking whether my code below is possible. I.e
Another newbie question: In the following code, what if the thread is preempted after
Another newbie question. I just wanted to know what exactly is the difference between
I have another newbie Python question. I have the following piece of code that
Another newbie question here, I have the following Select: SELECT DATEADD(dd, 0, DATEDIFF(dd, 0,
Another newbie question: What's the best way to store data in a Cocoa application
This is a super newbie question, I've been programming for a while, but am

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.