13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5: Using the Filesystem 139Listing 5-23. The FolderInfoPresenter Interface@interface FolderInfoPresenter : NSObject - (id) initWithFolderURL: (NSURL *) folderURL;@endInstances of FolderInfoPresenter are initialized with the URL of the (existing) folder that it willmonitor. You’ll notice that it declares that it conforms to the NSFilePresenter protocol.The class’s instance variables, declared as part of its implementation block, can be seen inListing 5-24.Listing 5-24. The FolderInfoPresenter Class’s Instance Variables@implementation FolderInfoPresenter{NSURL *_folderURL;// a pair of presenters, updated in alternationInfoFilePresenter * _infoFiles[2];NSUInteger_whichFile;NSOperationQueue * _queue;}@endNSUIntegerNSUIntegerBOOL_totalFileSize;_totalAllocatedSize;_suspended;First of all, you’ll see that it keeps track of its URL; as outlined above, an NSFilePresenter isexpected to return the URL of its presented item on demand.Next come the two log file presenters I mentioned, along with a variable referencing the arraylocation of the next one to be messaged. After this is a private NSOperationQueue instance, againto be returned as required by the NSFilePresenter protocol.Lastly you’ll see the two variables for the folder’s file size and disk allocation size plus a Booleanflag you’ll use to determine whether you should avoid scanning the folder hierarchy for a whiledue to file operations from other actors.The initializer sets up some of these variables, as seen in Listing 5-25.Listing 5-25. FolderInfoPresenter’s Initialization Method- (id) initWithFolderURL: (NSURL *) folderURL{self = [super init];if ( self == nil )return ( nil );www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!