FoundationExtension
FoundationExtension is common Foundation/UIKit/Cocoa shortcuts and snippets collection.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
FSEventStream Class Reference

FSEventSteam object wrapper. More...

#import <FSEventStream.h>

Inheritance diagram for FSEventStream:

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< FSEventStreamDelegatedelegate
 Delegate object for event stream. More...
 
FSEventStreamEventId latestEventId
 Latest event id of event stream. More...
 

Detailed Description

FSEventSteam object wrapper.

Interface design is based on NSTimer, if available. This doesn't work with App sandbox model.

See also
<FSEvents.h>

Method Documentation

- (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.

Returns
The largest event id of any event ever queued for this stream, otherwise zero if no events have been queued for this stream.
See also
FSEventStreamFlushAsync
- (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.

See also
FSEventStreamFlushSync
- (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.

Parameters
pathsArray of NSString, each specifying a path to a directory, signifying the root of a filesystem hierarchy to be watched for modifications.
latencyThe 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.
flagsFlags that modify the behavior of the stream being created. See FSEventStreamCreateFlags.
delegateThe 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.
See also
FSEventStreamCreate
- (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().

See also
FSEventStreamInvalidate
+ (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.

See also
- initWithPaths:latency:flags:delegate:
+ scheduledEventStreamWithPaths:latency:flags:delegate:
- scheduleWithRunLoop:mode:
+ (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.

See also
- initWithPaths:latency:flags:delegate:
- scheduleWithRunLoop:mode:
- (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.

Parameters
runLoopThe run loop on which to schedule the stream.
modeA run loop mode on which to schedule the stream.
See also
FSEventStreamScheduleWithRunLoop
- (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().

Returns
True if it succeeds, otherwise False if it fails. It ought to always succeed, but in the event it does not then your code should fall back to performing recursive scans of the directories of interest as appropriate.
See also
FSEventStreamStart
- (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").

See also
FSEventStreamStop
- (void) unscheduleFromRunLoop: (NSRunLoop *)  runLoop
mode: (NSString *)  mode 

This method removes the stream from the specified run loop.

Like CFRunLoopRemoveSource() does for a CFRunLoopSourceRef.

See also
FSEventStreamUnscheduleFromRunLoop

Member Data Documentation

- (id<FSEventStreamDelegate> __unsafe_unretained) _delegate
protected
- (NSUInteger) _managedRetainCount
protected
- (FSEventStreamRef) _stream
protected

Property Documentation

- (id<FSEventStreamDelegate>) delegate
readwritenonatomicunsafe_unretained

Delegate object for event stream.

- (FSEventStreamEventId) latestEventId
readnonatomicassign

Latest event id of event stream.


The documentation for this class was generated from the following file: