• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Request for help in getting table View to reflect fetch results
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Request for help in getting table View to reflect fetch results


  • Subject: Request for help in getting table View to reflect fetch results
  • From: "Ernest Schaal" <email@hidden>
  • Date: Sun, 15 Jul 2007 10:46:32 +0900

For the past six months, I have been giving presentations to the
Nagoya International Personal Computer Club on developing a data base
using core data:
(http://web.mac.com/eschaal/iWeb/Docketer Project/Welcome.html)

This mailing list has been a great help. We have created a Core Data
Document-based Application with three entities, and use one tabbed
window of the myDocument.nib to enter and present the data. the tabbed
views each have a tableView that was created by option-dragging an
entity from the data model to the tableView. The three entities are to
project, event, and time record.

The next lesson is about the methods used to fetched and display
events that are due within a given period of time. Thanks to help from
this group I was able to do the fetch that retrieves items due within
that period that have not been completed, but I haven't figured out
how to apply that fetch to a table view.

- (void)windowControllerDidLoadNib:(NSWindowController *)windowController
{
	int choice;
	NSTimeInterval secondsPerDay = 24 * 60 * 60;
	NSTimeInterval secondsPerPeriod;
	NSDate *today = [NSDate date];

	[super windowControllerDidLoadNib:windowController];

	// Get the Warning Date
	NSUserDefaults *defaults;
	defaults = [NSUserDefaults standardUserDefaults];
	warningTimePeriod = [defaults floatForKey:BNRNmbrDays];
	secondsPerPeriod = secondsPerDay * warningTimePeriod;
	warningDate = [today addTimeInterval:secondsPerPeriod];

	// Log the Warning Day
	NSLog (@"Warning Date is %@", [warningDate description]);

	// Develop Fetch request for items within warning period
	NSManagedObjectContext *context = [self managedObjectContext];
	NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
	[request setEntity:[NSEntityDescription entityForName:@"event"
inManagedObjectContext:context]];
	[request setPredicate:[NSPredicate predicateWithFormat:@"(dateDone ==
nil) AND (date < %@)", warningDate]];

	// Log the Fetch request
	NSLog (@"Fetch: %@", [request description]);

	// Perform the Fetch
	NSError *error = nil;
	NSArray *eventsDue = [context executeFetchRequest:request error:&error];
	NSAssert(eventsDue != nil, ([NSString stringWithFormat:@"Fetch
Failed: %@", error]));
	alertCount = [eventsDue count];

	// Log the alert Count
	NSLog (@"Alert Count: %u", alertCount);

	// Run an alert panel
	if (alertCount > 0)
		{
		choice = NSRunAlertPanel(@"Events due",
			@"You have %u events due within the warning period. Do you want to
fetch them now?",
			@"Yes", @"No", nil, alertCount);

		// If the user chooses Yes, limit the selection
		if (choice == NSAlertDefaultReturn)
			{
			// The Fetch button was clicked
			NSLog(@"Fetch requested");

			// Where I hope to put the connections to the display
			}
		}
		else
			choice =  NSRunAlertPanel(@"No Events Due", @"There are no items
due within the warning period", NULL, NULL, NULL);
}

@end
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Request for help in getting table View to reflect fetch results
      • From: Chris Hanson <email@hidden>
    • Re: Request for help in getting table View to reflect fetch results
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: NSApplicationMain options
  • Next by Date: Re: Request for help in getting table View to reflect fetch results
  • Previous by thread: [ANN] UKSoundFileRecorder
  • Next by thread: Re: Request for help in getting table View to reflect fetch results
  • Index(es):
    • Date
    • Thread