FoundationExtension
FoundationExtension is common Foundation/UIKit/Cocoa shortcuts and snippets collection.
|
FSEventSteam object wrapper. More...
#import <FSEventStream.h>
Instance Methods | |
(instancetype) | - initWithPaths:latency:flags:delegate: |
Returns an initiailized event stream with given paths, latency, create flags and delegate. More... | |
(void) | - invalidate |
Invalidates the stream. More... | |
(BOOL) | - start |
Attempts to register with the FS Events service to receive events per the parameters in the stream. More... | |
(void) | - stop |
Unregisters with the FS Events service. More... | |
(void) | - scheduleWithRunLoop:mode: |
Schedules the stream on the specified run loop. More... | |
(void) | - unscheduleFromRunLoop:mode: |
This method removes the stream from the specified run loop. More... | |
(FSEventStreamEventId) | - flushAsync |
Asks the FS Events service to flush out any events that have occurred but have not yet been delivered, due to the latency parameter that was supplied when the stream was created. More... | |
(void) | - flushSync |
Asks the FS Events service to flush out any events that have occurred but have not yet been delivered, due to the latency parameter that was supplied when the stream was created. More... | |
Class Methods | |
(instancetype) | + scheduledEventStreamWithPaths:latency:flags:delegate: |
Returns a created and scheduled event stream with given paths, latency, create flags and delegate. More... | |
(instancetype) | + scheduledEventStreamWithPath:latency:flags:delegate: |
Returns a created and scheduled event stream with given path, latency, create flags and delegate. More... | |
Protected Attributes | |
FSEventStreamRef | _stream |
id< FSEventStreamDelegate > __unsafe_unretained | _delegate |
NSUInteger | _managedRetainCount |
Properties | |
id< FSEventStreamDelegate > | delegate |
Delegate object for event stream. More... | |
FSEventStreamEventId | latestEventId |
Latest event id of event stream. More... | |
FSEventSteam object wrapper.
Interface design is based on NSTimer, if available. This doesn't work with App sandbox model.
- (FSEventStreamEventId) flushAsync |
Asks the FS Events service to flush out any events that have occurred but have not yet been delivered, due to the latency parameter that was supplied when the stream was created.
This flushing occurs asynchronously – do not expect the events to have already been delivered by the time this call returns.
This method can only be called after the stream has been started, via start.
- (void) flushSync |
Asks the FS Events service to flush out any events that have occurred but have not yet been delivered, due to the latency parameter that was supplied when the stream was created.
This flushing occurs synchronously – by the time this call returns, your callback will have been invoked for every event that had already occurred at the time you made this call.
This method can only be called after the stream has been started, via start.
- (instancetype) initWithPaths: | (NSArray *) | paths | |
latency: | (NSTimeInterval) | latency | |
flags: | (FSEventStreamCreateFlags) | flags | |
delegate: | (id) | delegate | |
Returns an initiailized event stream with given paths, latency, create flags and delegate.
paths | Array of NSString, each specifying a path to a directory, signifying the root of a filesystem hierarchy to be watched for modifications. |
latency | The number of seconds the service should wait after hearing about an event from the kernel before passing it along to the client via its callback. Specifying a larger value may result in more effective temporal coalescing, resulting in fewer callbacks and greater overall efficiency. |
flags | Flags that modify the behavior of the stream being created. See FSEventStreamCreateFlags. |
delegate | The delegate object for the connection. The delegate will receive delegate messages as the file system event. Messages to the delegate will be sent on the thread that calls this method. By default, for the connection to work correctly, the calling thread’s run loop must be operating in the default run loop mode. |
- (void) invalidate |
Invalidates the stream.
Invalidates the stream, like CFRunLoopSourceInvalidate() does for a CFRunLoopSourceRef. It will be unscheduled from any runloops or dispatch queues upon which it had been scheduled.
invalidate can only be called on the stream after you have called scheduleWithRunLoop:mode: or FSEventStreamSetDispatchQueue().
+ (instancetype) scheduledEventStreamWithPath: | (NSString *) | path | |
latency: | (NSTimeInterval) | latency | |
flags: | (FSEventStreamCreateFlags) | flags | |
delegate: | (id) | delegate | |
Returns a created and scheduled event stream with given path, latency, create flags and delegate.
+ (instancetype) scheduledEventStreamWithPaths: | (NSArray *) | paths | |
latency: | (NSTimeInterval) | latency | |
flags: | (FSEventStreamCreateFlags) | flags | |
delegate: | (id) | delegate | |
Returns a created and scheduled event stream with given paths, latency, create flags and delegate.
- (void) scheduleWithRunLoop: | (NSRunLoop *) | runLoop | |
mode: | (NSString *) | mode | |
Schedules the stream on the specified run loop.
This method schedules the stream on the specified run loop, like CFRunLoopAddSource() does for a CFRunLoopSourceRef. The caller is responsible for ensuring that the stream is scheduled on at least one run loop and that at least one of the run loops on which the stream is scheduled is being run.
To start receiving events on the stream, call start.
To remove the stream from the run loops upon which it has been scheduled, call unscheduleFromRunLoop:mode: or invalidate.
runLoop | The run loop on which to schedule the stream. |
mode | A run loop mode on which to schedule the stream. |
- (BOOL) start |
Attempts to register with the FS Events service to receive events per the parameters in the stream.
This method can only be called once the stream has been scheduled on at least one runloop, via scheduleWithRunLoop:mode:.
Once started, the stream can be stopped via FSEventStreamStop().
- (void) stop |
Unregisters with the FS Events service.
The client callback will not be called for this stream while it is stopped.
This method can only be called if the stream has been started, via start.
Once stopped, the stream can be restarted via start, at which point it will resume receiving events from where it left off ("sinceWhen").
- (void) unscheduleFromRunLoop: | (NSRunLoop *) | runLoop | |
mode: | (NSString *) | mode | |
This method removes the stream from the specified run loop.
Like CFRunLoopRemoveSource() does for a CFRunLoopSourceRef.
|
protected |
|
protected |
|
protected |
|
readwritenonatomicunsafe_unretained |
Delegate object for event stream.
|
readnonatomicassign |
Latest event id of event stream.