• 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
Re: Core Data "Uniqueing" not happening as expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data "Uniqueing" not happening as expected


  • Subject: Re: Core Data "Uniqueing" not happening as expected
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 21 Jun 2009 13:23:57 -0700


On 2009 Jun 21, at 09:55, Quincey Morris wrote:

Unless you can see 2 different objects with the same UID ...

More precisely, you mean "the same -objectID".

Yup. To our surprise, my fetch request is returning two objects with the same objectID, or from a Core Data perspective, I suppose you'd call it two copies of the same managed object.

Here's the fetching code from the NSPersistentDocument subclass in my actual project:

NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init] ;
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Browfile_entity"
inManagedObjectContext:[self managedObjectContext]]] ;
NSError* error_ = nil ;
NSArray* mocBrowfiles = [[self managedObjectContext] executeFetchRequest:fetchRequest
error:&error_] ;
[fetchRequest release] ;
if (error_) {
// Handle error
... this does not execute ...
}
NSLog(
@"46985: uniqueIDs of fetched objects:\n%@",
[mocBrowfiles valueForKey:@"stringID"]
) ;


NSLog(@"47115: pointers to fetched objects:\n") ;
for (Browfile* browfile in mocBrowfiles) {
    NSLog(@"    %p", browfile) ;
}


Here's my -[NSManagedObject stringID] method:

- (NSString*)stringID {
    NSManagedObjectID* objectID = [self objectID] ;
    NSString* string = [[objectID URIRepresentation] absoluteString] ;
    NSString* suffix = [objectID isTemporaryID] ? @"temp" : @"perm" ;
    return [NSString stringWithFormat:
            @"%@[%@]",
            string,
            suffix] ;
}


Here's the console output:

2009-06-21 13:04:00.993 TestApp[77117:10b] 46985: uniqueIDs of fetched objects:
(
"x-coredata://101E2F60-412A-41EE-9DEF-59797757C29C/ Browfile_entity/p1[perm]",
"x-coredata://101E2F60-412A-41EE-9DEF-59797757C29C/ Browfile_entity/p2[perm]"
)
2009-06-21 13:04:00.995 TestApp[77117:10b] 47115: pointers to fetched objects:
2009-06-21 13:04:00.999 TestApp[77117:10b] 0x16e0c9b0
2009-06-21 13:04:01.006 TestApp[77117:10b] 0x16e43f20


I believe that I inserted one Browfile object into the store. But even if I screwed up somewhere and actually inserted two, why does this fetch request return two objects with exactly the same permanent objectID? Has anyone ever seen that?

It's not the fact that I'm using an SQLite store. I tried my little utility project with an SQLite store, and saving it, and it works correctly. It still only returns one Bar (aka Browfile).


_______________________________________________

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: Core Data "Uniqueing" not happening as expected
      • From: mmalc Crawford <email@hidden>
    • Re: Core Data "Uniqueing" not happening as expected
      • From: Jerry Krinock <email@hidden>
References: 
 >Core Data "Uniqueing" not happening as expected (From: Jerry Krinock <email@hidden>)
 >Re: Core Data "Uniqueing" not happening as expected (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Core Data "Uniqueing" not happening as expected
  • Next by Date: Re: Core Data "Uniqueing" not happening as expected
  • Previous by thread: Re: Core Data "Uniqueing" not happening as expected
  • Next by thread: Re: Core Data "Uniqueing" not happening as expected
  • Index(es):
    • Date
    • Thread