On Oct 27, 2016, at 19:00:14, Dave Fernandes <dave.fernan...@utoronto.ca> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to