• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Identifying complete size of file when transfer is in progress
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Identifying complete size of file when transfer is in progress


  • Subject: Identifying complete size of file when transfer is in progress
  • From: Devarshi Kulshreshtha <email@hidden>
  • Date: Fri, 15 Nov 2013 15:28:59 -0600

In my iphone app, I am displaying information of files added to documents
directory, in a table view, as soon as those are added. For this I am using
DirectoryWatcher class provided in one of the sample codes by apple.

Below is the block of code showing its use:

- (void)viewDidLoad
{
    // start monitoring the document directory…
    self.aDirectoryWatcher = [DirectoryWatcher watchFolderWithPath:[self
applicationDocumentsDirectory] delegate:self];

    // scan for existing documents
    [self directoryDidChange:self.aDirectoryWatcher];
}

- (void)directoryDidChange:(DirectoryWatcher *)folderWatcher
{
[self reconcileData];
}

One of the information displayed in table view cell is- file size, which I
am obtaining as below:

NSDictionary *fileAttributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:[fileURL path] error:nil];
NSNumber * size = [fileAttributes objectForKey:NSFileSize];

Problem is-

When I am trying to add a large file, such as a movie file, then as soon as
transfer starts (copy or move operation) it invokes directoryDidChange:
immediately. It did not wait unless the transfer is complete. So I always
get size as 0.
In case of small sized files, such as images, it works fine.

Now I have two question:

1. Is there any way to know the complete size of file, which is in transfer
state. eg. if message displayed is copying 30 MB of 100 MB, I want to get
100 MB?

2. Is there any alternative of DirectoryWatcher, which notifies only when
file is completely added?

Please suggest.

--
Thanks,

Devarshi
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Identifying complete size of file when transfer is in progress
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: PDFView not rendering pages on scroll
  • Next by Date: Deleting 20000 files in applicationWillTerminate
  • Previous by thread: CoreData error after moving to Xcode 5
  • Next by thread: Re: Identifying complete size of file when transfer is in progress
  • Index(es):
    • Date
    • Thread