Hi All,
This is the code I have so far. What I need to do is retrieve RecId conents which contains a integer.
I need to know what I am missing to get the last recId from my core data attribute entered that is in the database.
Can anyone point me in the direction or give a proper example of how to retrieve the last Entity with the attribute recId to insert into my new Entity...?
Thanks In Advance,
Kiefer
This is the code I have so far. What I need to do is retrieve RecId conents which contains a integer.
Code:
- (IBAction)myButton:sender
{
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"EEEE, MMMM d, yyyy -- h:mm a"];
NSString *dateTime = [NSString stringWithFormat:@"%@",[outputFormatter stringFromDate:[NSDate date]]];
int myresult = [recid.stringValue intValue]; [COLOR="Red"]<<<--- This what I am using to try and return recId from my Entity. This only returns 0.[/COLOR]
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *entity = [NSEntityDescription
insertNewObjectForEntityForName:@"Entry"
inManagedObjectContext:context];
[arrayController addObject:entity];
int entityCount = 0;
NSEntityDescription *myentity = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:myentity];
[fetchRequest setIncludesPropertyValues:YES];
[fetchRequest setIncludesSubentities:NO];
NSError *error = nil;
NSUInteger count = [managedObjectContext countForFetchRequest: fetchRequest error: &error];
if(error == nil){
entityCount = count;
}
int myRowCount = [NSNumber numberWithInt:count];
myresult + 1; <<<--- Then add 1 here to recId.
[entity setValue:myreslut forKey:@"recId"]; [COLOR="Red"]<<<--- Set the new recId for my new Entity from myresult; myresult is still returning 0 here...[/COLOR]
[entity setValue:dateTime forKey:@"date"];
[textField becomeFirstResponder];
}
I need to know what I am missing to get the last recId from my core data attribute entered that is in the database.
Can anyone point me in the direction or give a proper example of how to retrieve the last Entity with the attribute recId to insert into my new Entity...?
Thanks In Advance,
Kiefer
Last edited by a moderator: