Skip to content

Commit 08c19ee

Browse files
committed
Merge branch 'release/1.2.0'
* release/1.2.0: (32 commits) Bump copyright years. Change framework version to 1.2.0. Update podspec to 1.2.0. Add compile time check of ARC and blocks. Update Xcode project. Fix ARC setting in podspec. Add podspec by @dwlnetnl (#13). Remove link to GitHub messages. Correctly handle path that contains spaces Made CDEvents class create CDEvent objects with file URLs instead of normal URLs (allows easier comparison with NSURL objects returned by eg. NSFileManager) Update README.mdown Fix contributors URL. Change the authors section in the readme. Update readme with link to new website. Ignore "docs" directory. Update readme to reflect online documentation. Add license file. Add script to generate documentation using appledoc. Update the read me to reflect the new changes. Update the test app to be able to use blocks API. ...
2 parents d560344 + 5beb7cd commit 08c19ee

File tree

14 files changed

+482
-157
lines changed

14 files changed

+482
-157
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
*.pbxproj binary
21
*.m diff=objc
32
*.mm diff=objc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ build
2727
*~.xib
2828

2929
api
30+
docs

CDEvent.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* CDEvents
33
*
4-
* Copyright (c) 2010 Aron Cedercrantz
4+
* Copyright (c) 2010-2012 Aron Cedercrantz
55
* http://github.com/rastersize/CDEvents/
66
*
77
* Permission is hereby granted, free of charge, to any person
@@ -67,13 +67,7 @@ typedef FSEventStreamEventFlags CDEventFlags;
6767
*
6868
* @since 1.0.0
6969
*/
70-
@interface CDEvent : NSObject <NSCoding, NSCopying> {
71-
@private
72-
CDEventIdentifier _identifier;
73-
NSDate *_date;
74-
NSURL *_URL;
75-
CDEventFlags _flags;
76-
}
70+
@interface CDEvent : NSObject <NSCoding, NSCopying> {}
7771

7872
#pragma mark Properties
7973
/** @name Getting Event Properties */
@@ -95,7 +89,7 @@ typedef FSEventStreamEventFlags CDEventFlags;
9589
*
9690
* @since 1.0.0
9791
*/
98-
@property (readonly) NSDate *date;
92+
@property (unsafe_unretained, readonly) NSDate *date;
9993

10094
/**
10195
* The URL of the item which changed.
@@ -104,7 +98,7 @@ typedef FSEventStreamEventFlags CDEventFlags;
10498
*
10599
* @since 1.0.0
106100
*/
107-
@property (readonly) NSURL *URL;
101+
@property (unsafe_unretained, readonly) NSURL *URL;
108102

109103

110104
/** @name Getting Event Flags */

CDEvent.m

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* CDEvents
33
*
4-
* Copyright (c) 2010 Aron Cedercrantz
4+
* Copyright (c) 2010-2012 Aron Cedercrantz
55
* http://github.com/rastersize/CDEvents/
66
*
77
* Permission is hereby granted, free of charge, to any person
@@ -44,22 +44,14 @@ + (CDEvent *)eventWithIdentifier:(NSUInteger)identifier
4444
URL:(NSURL *)URL
4545
flags:(CDEventFlags)flags
4646
{
47-
return [[[CDEvent alloc] initWithIdentifier:identifier
47+
return [[CDEvent alloc] initWithIdentifier:identifier
4848
date:date
4949
URL:URL
50-
flags:flags]
51-
autorelease];
50+
flags:flags];
5251
}
5352

5453

5554
#pragma mark Init/dealloc methods
56-
- (void)dealloc
57-
{
58-
[_date release];
59-
[_URL release];
60-
61-
[super dealloc];
62-
}
6355

6456
- (id)initWithIdentifier:(NSUInteger)identifier
6557
date:(NSDate *)date
@@ -69,8 +61,8 @@ - (id)initWithIdentifier:(NSUInteger)identifier
6961
if ((self = [super init])) {
7062
_identifier = identifier;
7163
_flags = flags;
72-
_date = [date retain];
73-
_URL = [URL retain];
64+
_date = date;
65+
_URL = URL;
7466
}
7567

7668
return self;
@@ -101,7 +93,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
10193
- (id)copyWithZone:(NSZone *)zone
10294
{
10395
// We can do this since we are immutable.
104-
return [self retain];
96+
return self;
10597
}
10698

10799
#pragma mark Specific flag properties

CDEvents.h

Lines changed: 132 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* CDEvents
33
*
4-
* Copyright (c) 2010 Aron Cedercrantz
4+
* Copyright (c) 2010-2012 Aron Cedercrantz
55
* http://github.com/rastersize/CDEvents/
66
*
77
* Permission is hereby granted, free of charge, to any person
@@ -94,6 +94,17 @@ extern const CDEventsEventStreamCreationFlags kCDEventsDefaultEventStreamFlags;
9494
extern const CDEventIdentifier kCDEventsSinceEventNow;
9595

9696

97+
#pragma mark -
98+
#pragma mark CDEvents Block Type
99+
@class CDEvents;
100+
/**
101+
* Type of the block which gets called when an event occurs.
102+
*
103+
* @since head
104+
*/
105+
typedef void (^CDEventsEventBlock)(CDEvents *watcher, CDEvent *event);
106+
107+
97108
#pragma mark -
98109
#pragma mark CDEvents interface
99110
/**
@@ -105,23 +116,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
105116
*
106117
* @since 1.0.0
107118
*/
108-
@interface CDEvents : NSObject <NSCopying> {
109-
@private
110-
__weak id<CDEventsDelegate> _delegate;
111-
112-
FSEventStreamRef _eventStream;
113-
CFTimeInterval _notificationLatency;
114-
115-
CDEventIdentifier _sinceEventIdentifier;
116-
NSUInteger _eventStreamCreationFlags;
117-
118-
BOOL _ignoreEventsFromSubDirectories;
119-
120-
CDEvent *_lastEvent;
121-
122-
NSArray *_watchedURLs;
123-
NSArray *_excludedURLs;
124-
}
119+
@interface CDEvents : NSObject <NSCopying> {}
125120

126121
#pragma mark Properties
127122
/** @name Managing the Delegate */
@@ -135,7 +130,17 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
135130
*
136131
* @since 1.0.0
137132
*/
138-
@property (assign) __weak id<CDEventsDelegate> delegate;
133+
@property (unsafe_unretained) id<CDEventsDelegate> delegate;
134+
135+
/** @name Getting Event Block */
136+
/**
137+
* The event block.
138+
*
139+
* @return The CDEventsEventBlock block which is executed when an event occurs.
140+
*
141+
* @since head
142+
*/
143+
@property (readonly) CDEventsEventBlock eventBlock;
139144

140145
/** @name Getting Event Watcher Properties */
141146
/**
@@ -145,7 +150,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
145150
*
146151
* @since 1.0.0
147152
*/
148-
@property (readonly) CFTimeInterval notificationLatency;
153+
@property (readonly) CFTimeInterval notificationLatency;
149154

150155
/**
151156
* The event identifier from which events will be supplied to the delegate.
@@ -154,16 +159,16 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
154159
*
155160
* @since 1.0.0
156161
*/
157-
@property (readonly) CDEventIdentifier sinceEventIdentifier;
162+
@property (readonly) CDEventIdentifier sinceEventIdentifier;
158163

159164
/**
160-
* The last event that occured and thas has been delivered to the delegate.
165+
* The last event that occured and has been delivered to the delegate.
161166
*
162-
* @return The last event that occured and thas has been delivered to the delegate.
167+
* @return The last event that occured and has been delivered to the delegate.
163168
*
164169
* @since 1.0.0
165170
*/
166-
@property (retain, readonly) CDEvent *lastEvent;
171+
@property (strong, readonly) CDEvent *lastEvent;
167172

168173
/**
169174
* The URLs that we watch for events.
@@ -172,7 +177,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
172177
*
173178
* @since 1.0.0
174179
*/
175-
@property (readonly) NSArray *watchedURLs;
180+
@property (copy, readonly) NSArray *watchedURLs;
176181

177182

178183
/** @name Configuring the Event watcher */
@@ -184,7 +189,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
184189
*
185190
* @since 1.0.0
186191
*/
187-
@property (copy) NSArray *excludedURLs;
192+
@property (copy) NSArray *excludedURLs;
188193

189194
/**
190195
* Wheter events from sub-directories of the watched URLs should be ignored or not.
@@ -194,7 +199,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
194199
*
195200
* @since 1.0.0
196201
*/
197-
@property (assign) BOOL ignoreEventsFromSubDirectories;
202+
@property (assign) BOOL ignoreEventsFromSubDirectories;
198203

199204

200205
#pragma mark Event identifier class methods
@@ -211,8 +216,8 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
211216
+ (CDEventIdentifier)currentEventIdentifier;
212217

213218

214-
#pragma mark Init methods
215-
/** @name Creating CDEvents Objects */
219+
#pragma mark Creating CDEvents Objects With a Delegate
220+
/** @name Creating CDEvents Objects With a Delegate */
216221
/**
217222
* Returns an <code>CDEvents</code> object initialized with the given URLs to watch.
218223
*
@@ -271,8 +276,6 @@ extern const CDEventIdentifier kCDEventsSinceEventNow;
271276
delegate:(id<CDEventsDelegate>)delegate
272277
onRunLoop:(NSRunLoop *)runLoop;
273278

274-
275-
276279
/**
277280
* Returns an <code>CDEvents</code> object initialized with the given URLs to watch, URLs to exclude, wheter events from sub-directories are ignored or not and schedules the watcher on the given run loop.
278281
*
@@ -311,6 +314,104 @@ ignoreEventsFromSubDirs:(BOOL)ignoreEventsFromSubDirs
311314
excludeURLs:(NSArray *)exludeURLs
312315
streamCreationFlags:(CDEventsEventStreamCreationFlags)streamCreationFlags;
313316

317+
#pragma mark Creating CDEvents Objects With a Block
318+
/** @name Creating CDEvents Objects With a Block */
319+
/**
320+
* Returns an <code>CDEvents</code> object initialized with the given URLs to watch.
321+
*
322+
* @param URLs An array of URLs we want to watch.
323+
* @param block The block which the CDEvents object executes when it recieves an event.
324+
* @return An CDEvents object initialized with the given URLs to watch.
325+
* @throws NSInvalidArgumentException if <em>URLs</em> is empty or points to <code>nil</code>.
326+
* @throws NSInvalidArgumentException if <em>delegate</em>is <code>nil</code>.
327+
* @throws CDEventsEventStreamCreationFailureException if we failed to create a event stream.
328+
*
329+
* @see initWithURLs:delegate:onRunLoop:
330+
* @see initWithURLs:delegate:onRunLoop:sinceEventIdentifier:notificationLantency:ignoreEventsFromSubDirs:excludeURLs:streamCreationFlags:
331+
* @see CDEventsEventBlock
332+
* @see kCDEventsDefaultEventStreamFlags
333+
* @see kCDEventsSinceEventNow
334+
*
335+
* @discussion Calls initWithURLs:block:onRunLoop:sinceEventIdentifier:notificationLantency:ignoreEventsFromSubDirs:excludeURLs:streamCreationFlags:
336+
* with <code>sinceEventIdentifier</code> with the event identifier for "event
337+
* since now", <code>notificationLatency</code> set to 3.0 seconds,
338+
* <code>ignoreEventsFromSubDirectories</code> set to <code>NO</code>,
339+
* <code>excludedURLs</code> to <code>nil</code>, the event stream creation
340+
* flags will be set to <code>kCDEventsDefaultEventStreamFlags</code> and
341+
* schedueled on the current run loop.
342+
*
343+
* @since head
344+
*/
345+
- (id)initWithURLs:(NSArray *)URLs block:(CDEventsEventBlock)block;
346+
347+
/**
348+
* Returns an <code>CDEvents</code> object initialized with the given URLs to watch and schedules the watcher on the given run loop.
349+
*
350+
* @param URLs An array of URLs we want to watch.
351+
* @param block The block which the CDEvents object executes when it recieves an event.
352+
* @param runLoop The run loop which the which the watcher should be schedueled on.
353+
* @return An CDEvents object initialized with the given URLs to watch.
354+
* @throws NSInvalidArgumentException if <em>URLs</em> is empty or points to <code>nil</code>.
355+
* @throws NSInvalidArgumentException if <em>delegate</em>is <code>nil</code>.
356+
* @throws CDEventsEventStreamCreationFailureException if we failed to create a event stream.
357+
*
358+
* @see initWithURLs:delegate:
359+
* @see initWithURLs:delegate:onRunLoop:sinceEventIdentifier:notificationLantency:ignoreEventsFromSubDirs:excludeURLs:streamCreationFlags:
360+
* @see CDEventsEventBlock
361+
* @see kCDEventsDefaultEventStreamFlags
362+
* @see kCDEventsSinceEventNow
363+
*
364+
* @discussion Calls initWithURLs:delegate:onRunLoop:sinceEventIdentifier:notificationLantency:ignoreEventsFromSubDirs:excludeURLs:streamCreationFlags:
365+
* with <code>sinceEventIdentifier</code> with the event identifier for "event
366+
* since now", <code>notificationLatency</code> set to 3.0 seconds,
367+
* <code>ignoreEventsFromSubDirectories</code> set to <code>NO</code>,
368+
* <code>excludedURLs</code> to <code>nil</code> and the event stream creation
369+
* flags will be set to <code>kCDEventsDefaultEventStreamFlags</code>.
370+
*
371+
* @since head
372+
*/
373+
- (id)initWithURLs:(NSArray *)URLs
374+
block:(CDEventsEventBlock)block
375+
onRunLoop:(NSRunLoop *)runLoop;
376+
377+
/**
378+
* Returns an <code>CDEvents</code> object initialized with the given URLs to watch, URLs to exclude, wheter events from sub-directories are ignored or not and schedules the watcher on the given run loop.
379+
*
380+
* @param URLs An array of URLs (<code>NSURL</code>) we want to watch.
381+
* @param block The block which the CDEvents object executes when it recieves an event.
382+
* @param runLoop The run loop which the which the watcher should be schedueled on.
383+
* @param sinceEventIdentifier Events that have happened after the given event identifier will be supplied.
384+
* @param notificationLatency The (approximate) time intervall between notifications sent to the delegate.
385+
* @param ignoreEventsFromSubDirs Wheter events from sub-directories of the watched URLs should be ignored or not.
386+
* @param exludeURLs An array of URLs that we should ignore events from. Pass <code>nil</code> if none should be excluded.
387+
* @param streamCreationFlags The event stream creation flags.
388+
* @return An CDEvents object initialized with the given URLs to watch, URLs to exclude, wheter events from sub-directories are ignored or not and run on the given run loop.
389+
* @throws NSInvalidArgumentException if the parameter URLs is empty or points to <code>nil</code>.
390+
* @throws NSInvalidArgumentException if <em>delegate</em>is <code>nil</code>.
391+
* @throws CDEventsEventStreamCreationFailureException if we failed to create a event stream.
392+
*
393+
* @see initWithURLs:delegate:
394+
* @see initWithURLs:delegate:onRunLoop:
395+
* @see ignoreEventsFromSubDirectories
396+
* @see excludedURLs
397+
* @see CDEventsEventBlock
398+
* @see FSEventStreamCreateFlags
399+
*
400+
* @discussion To ask for events "since now" pass the return value of
401+
* currentEventIdentifier as the parameter <code>sinceEventIdentifier</code>.
402+
* CDEventStreamCreationFailureException should be extremely rare.
403+
*
404+
* @since head
405+
*/
406+
- (id)initWithURLs:(NSArray *)URLs
407+
block:(CDEventsEventBlock)block
408+
onRunLoop:(NSRunLoop *)runLoop
409+
sinceEventIdentifier:(CDEventIdentifier)sinceEventIdentifier
410+
notificationLantency:(CFTimeInterval)notificationLatency
411+
ignoreEventsFromSubDirs:(BOOL)ignoreEventsFromSubDirs
412+
excludeURLs:(NSArray *)exludeURLs
413+
streamCreationFlags:(CDEventsEventStreamCreationFlags)streamCreationFlags;
414+
314415
#pragma mark Flush methods
315416
/** @name Flushing Events */
316417
/**

0 commit comments

Comments
 (0)