• 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
error trying to save in Coredata
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

error trying to save in Coredata


  • Subject: error trying to save in Coredata
  • From: Harish Yarlagadda <email@hidden>
  • Date: Thu, 15 Oct 2009 17:11:08 -0700 (PDT)

Hope someone can help me. I am getting the following CoreData error. I am using core data 3.0 on snow leopard for a iPhone application.



2009-10-15 18:42:27.452 SB[4131:207] Domain NSCocoaErrorDomain

2009-10-15 18:42:27.453 SB[4131:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1570 UserInfo=0x1224360 "Operation could not be completed. (Cocoa error 1570.)", {

    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1570.)";

    NSValidationErrorKey = date;

    NSValidationErrorObject = <Match: 0x10320d0> (entity: Match; id: 0x1032180 <x-coredata:///Match/tFAADEB47-DAE8-484B-A109-65BAEFEC50392> ; data: {

    date = nil;

    matchinnings =     (

    );

    teams =     (

    );

    venue = nil;

});

}


Entity: Match

Attribute: date (NSDate)

Attribute: venue (NSString)

Relationship: matchinnings (NSSet, 1 to many)

Relationship: teams (NSSet, 1 to many)


Entity: Innings

Attribute: number (NSNumber)

relationship: matchinnings (Match, Many to 1)


Code:


@interface Innings : NSManagedObject {


}



//@property (nonatomic, retain) NSString *batting;

//@property (nonatomic, retain) NSString *bowling;

@property (nonatomic, retain) NSNumber *number;

@property (nonatomic, retain) Match *matchinnings;


@end


@interface Match : NSManagedObject {

}


@property (nonatomic, retain) NSDate *date;

@property (nonatomic, retain) NSSet *teams;

//@property (nonatomic, retain) Team *visitingTeam;

//@property (nonatomic, retain) Team *tossWonBy;

//@property (nonatomic, retain) Team *electedTo;

@property (nonatomic, retain) NSString *venue;

@property (nonatomic, retain) NSSet *matchinnings;


@end


@interface Match (CoreDataGeneratedAccessors)


-(void)addMatchinningsObject:(NSManagedObject *)value;

-(void)removeMatchinningsObject:(NSManagedObject *) value;

-(void)addMatchinnings:(NSSet *)value;

-(void)removeMatchinnings:(NSSet *)value;


@end


@interface Match (DataGeneratedAccessors)


-(void)addTeamsObject:(NSManagedObject *)value;

-(void)removeTeamsObject:(NSManagedObject *) value;

-(void)addTeams:(NSSet *)value;

-(void)removeTeams:(NSSet *)value;


@end

- (void) save {

NSArray *teamObjectsArray = [self teamObjects];

Team *teamAObject = [teamObjectsArray objectAtIndex:0];

Team *teamBObject = [teamObjectsArray objectAtIndex:3];

NSManagedObjectContext *context = [teamAObject managedObjectContext];

match = [NSEntityDescription insertNewObjectForEntityForName:@"Match" inManagedObjectContext:context];

NSDate *day = [NSDate date];

NSLog(@"Date: %@", day);

// [match setDate:[NSDate date]];

// [match setVenue:venueTextField.text];

match.date = [NSDate date];

match.venue = venueTextField.text;[NSDate date];

//NSArray *teamsRetrieved = [self retrieveTeams];


//NSString *teamBName = [teamsRetrieved objectAtIndex:[viewA selectedRowInComponent:0]];


[match addTeamsObject:teamAObject];

[match addTeamsObject:teamBObject];

//[match addTeams:teamsPlaying];

inningsA = [NSEntityDescription insertNewObjectForEntityForName:@"Innings" inManagedObjectContext:self.managedObjectContext];

inningsB = [NSEntityDescription insertNewObjectForEntityForName:@"Innings" inManagedObjectContext:self.managedObjectContext];

[inningsA setNumber:[NSNumber numberWithInt:1]];

[inningsB setNumber:[NSNumber numberWithInt:2]];

//innings = [NSSet setWithObjects:inningsA, inningsB, nil]; 

@try {

//[match addInnings:innings];

[match addMatchinningsObject:inningsA];

[match addMatchinningsObject:inningsB];

} 

@catch (NSException *exception) {

NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);

}

//Innings inningsA = nil; //[[Innings alloc] init];

//NSSet *inningsSet = [[NSSet alloc] initWithObjects:inningsA, inningsB];


NSError *error = nil;

if (![match.managedObjectContext save:&error]) {

/*

Replace this implementation with code to handle the error appropriately.

 

abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.

*/

NSString *domain = [error domain];

NSLog(@"Domain %@", domain);

NSLog(@"Unresolved error %@, %@", error, [error userInfo]);

NSLog(@"Errors %@", [error domain]); 

abort();

}

[self dismissModalViewControllerAnimated:YES];

}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: error trying to save in Coredata
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Interface builder & sample data
  • Next by Date: Re: Zombie app
  • Previous by thread: Re: Zombie app
  • Next by thread: Re: error trying to save in Coredata
  • Index(es):
    • Date
    • Thread