Skip to content

Instantly share code, notes, and snippets.

@brentsimmons
Created March 1, 2014 01:17
Show Gist options
  • Save brentsimmons/9283314 to your computer and use it in GitHub Desktop.
Save brentsimmons/9283314 to your computer and use it in GitHub Desktop.
//
// VSTagAuthority.h
// Vesper
//
// Created by Brent Simmons on 2/28/14.
// Copyright (c) 2014 Q Branch LLC. All rights reserved.
//
/*
Create only one of these.
Tags must be created using tagWithName only.
The worst-case scenario is when a tag doesn't exist.
It will block as it inserts the tag and saves its context.
*/
@class VSTag;
@interface VSTagAuthority : NSObject
- (instancetype)initWithPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)storeCoordinator;
/*These methods do [context objectWithID:], which means these should be called from within
a performBlock block (or whatever is appropriate for the context).*/
- (VSTag *)existingTagWithName:(NSString *)name context:(NSManagedObjectContext *)context;
- (VSTag *)tagWithName:(NSString *)name context:(NSManagedObjectContext *)context error:(NSError **)error;
/*Creates tag if needed. Error can happen on context save.*/
@end
@DivineDominion
Copy link

Thanks for taking the time to write about your progress! Care to share the method implementations? I'm deciding whether Core Data is a good choice if I pass around view model objects which map to the store via ID only.

Update: stupid me, it's just in another Gist: https://gist.github.com/brentsimmons/9283338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment