Re: CoreData headaches
Re: CoreData headaches
- Subject: Re: CoreData headaches
- From: Steve Mills <email@hidden>
- Date: Thu, 27 Oct 2016 22:24:18 -0500
On Oct 27, 2016, at 19:00:14, Dave Fernandes <email@hidden> wrote:
>
> Are you accessing the properties from within a NSManagedObjectContext.performBlock block? Sounds like you may be accessing the managed objects from the wrong queue.
I'll explain what's going on. Each NSCollectionViewItem in the NSCollectionView is being assigned its representedObject (the Asset, which is a reference to an image file). At that point, I ask the Asset to requestPreviewImageAtSize:, which creates an NSBlockOperation (and adds it to an NSOperationQueue), whose block creates a CGImageSourceRef. Before it can create the CGImageSourceRef, it needs to get the url. It does this by asking for its .folder and .name properties. Those are nonatomic properties of the Asset. Once it has the url and the CGImageSourceRef, it creates the CGImageRef, converts that to an NSImage, and finally assigns that to the Asset's atomic .thumb property.
The folder and name properties were generated by mogenerator, a tool for creating document model classes for CoreData .xcdatamodeld files. The thumb property is something I added manually to cache the thumbnail, and the AssetItemView's NSImageView's Value binds to it as well.
So I'm not directly dealing with any NSManagedObjectContext here. That's all taken care of when the items are added to it or when a document is opened. All I'm doing is generating a preview for each managed object.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
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