Database Reference
In-Depth Information
Next we will create a define that will be used for our file extension. We put this in this class because
it related specifically to this document rather than our entire project.
#define CT_EXTENSION @"ict"
Inside our interface we will create one public property for accessing our metadata, because our
metadata will actually be created by values from the data model on save this is safe.
@property (strong, nonatomic) CTMetadata *metadata;
We will then create a setter and getter method for each of our data properties. We do this because
we want to intercept all these calls rather than let the app access these properties directly.
-(NSString *)firstName;
-(void)setFirstName:(NSString *)firstName;
-(NSString *)lastName;
-(void)setLastName:(NSString *)lastName;
-(NSString *)displayName;
-(void)setDisplayName:(NSString *)displayName;
-(NSNumber *)favoriteNumber;
-(void)setFavoriteNumber:(NSNumber *)favoriteNumber;
-(UIImage *)photo;
-(void)setPhoto:(UIImage *)photo;
-(NSString *)description;
Now let's move on to our CTDocument.m file. First, we need to add some imports. Add these above
the CTDocument.h import.
#import "UIImage+Resize.h"
#import "CTData.h"
#import "CTMetadata.h"
Next, we will add two local constants that we will use in our implementation.
#define kDataKey @"ctdocument.data"
#define kMetadataKey @"ctdocument.metadata"
Now we need to create a private interface that will hold our CTData property and our NSFileWrapper
property.
@interface CTDocument()
@property (strong, nonatomic) CTData *data;
@property (strong, nonatomic) NSFileWrapper *fileWrapper;
@end
 
Search WWH ::




Custom Search