• 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
Re: FSCopyAsync Example + Updating UI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FSCopyAsync Example + Updating UI


  • Subject: Re: FSCopyAsync Example + Updating UI
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 23 Oct 2006 13:53:04 +0100

OK, it's actually fairly simple to do this in reality Mark. I've got part of my app up and running doing what you want, mainly due to various other bits of help from people on this list.

OK, so first you need a callback function, something like:

static void MAFileOperationAsyncCallback(FSFileOperationRef fileOp,
										 const FSRef *currentItem,
										 FSFileOperationStage stage,
										 OSStatus error,
										 CFDictionaryRef statusDictionary,
										 void *info)

To start the copy, use the FSCopyObjectAsync function. You need to feed it information about the source and destination FSRefs. Also, specify your callback function and a callback interval - I find 0.5 works pretty well. Most importantly though, you need to supply with that function a pointer to an object uniquely identifying that particular operation.

Then, use something like this to actually schedule your callback function:

FSFileOperationScheduleWithRunLoop(fileOpeRef,
								      [[NSRunLoop currentRunLoop] getCFRunLoop],
								      (CFStringRef)NSDefaultRunLoopMode);

After that you should be all set. In your callback function, use the *info pointer to find the object identifying that particular copy operation and call whatever methods you like in order to update a progress bar.

The best thing of all is that you don't even have to run this in a separate thread!

Mike.

On 23 Oct 2006, at 00:02, Mark Manes wrote:

Greetings,

I am looking for an example of how to properly implement FSCopyAsync that allows me to update the status of the UI during the callback. Clearly I can't call a method within the callback as I don't have the objects necessary. I see people discuss the use of NSRunLoop -- but I don't quite get it.

I'd love a working example that copied files and updated the progress using NSProgressIndicator.

Seems like a pretty common thing that people might want to do--I am sure it would benefit many of someone would take the time to show a good example.

PS: I did see the Apple documetnation on FSCopyAsync and in fact I have the code working that copies the files properly. I just want to tell my user what is going on. :)

Many thanks in advance!

-mark=

Mark D. Manes


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >FSCopyAsync Example + Updating UI (From: Mark Manes <email@hidden>)

  • Prev by Date: Re: Sending an ASCII string to a specific IP address
  • Next by Date: Re: NSTextView's -setTextContainerInset: issues
  • Previous by thread: Re: FSCopyAsync Example + Updating UI
  • Next by thread: Re: FSCopyAsync Example + Updating UI
  • Index(es):
    • Date
    • Thread