Database Reference
In-Depth Information
Create a new Objective-C class that is a subclass of NSObject and name it CTEntry . Because this
class is really only going to be handling the metadata we will want to add a class declaration for
CTMetadata .
@class CTMetadata;
Next we will add some public properties:
@property (strong) NSURL *fileURL;
@property (strong) CTMetadata *metadata;
@property (assign) UIDocumentState state;
@property (strong) NSFileVersion *version;
And finally we will add an initialization method that will handle setting these properties for us:
-(id)initWithFileURL:(NSURL *)fileURL metadata:(CTMetadata *)metadata state:(UIDocumentState)state
andVersion:(NSFileVersion *)version;
Now, let's move into the CTEntry.m file and add the initializer and set all of our properties to those
passed to it:
-(id)initWithFileURL:(NSURL *)fileURL metadata:(CTMetadata *)metadata state:(UIDocumentState)state
andVersion:(NSFileVersion *)version {
if((self = [super init])){
_fileURL = fileURL;
_metadata = metadata;
_state = state;
_version = version;
}
return self;
}
That wraps up our UIDocument setup. Now we need to move on and modify our code to use our
CTDocument instead of our generic NSString that we've been using so far.
Implementing CTDocument
Let's start by adding some imports to our FriendsCollectionViewController.m file:
#import "CTEntry.h"
#import "CTDocument.h"
#import "CTMetadata.h"
Now we need to add a property for the selectedDocument and adjust our selectedEntry to type
CTEntry :
@property (strong) CTDocument *selectedDocument;
@property (strong) CTEntry *selectedEntry;
 
Search WWH ::




Custom Search