Permalink
Browse files

Merge branch 'master' into production

Conflicts:
	DCTFoundation Project/DCTFoundation.xcodeproj/project.pbxproj
	Readme.textile
  • Loading branch information...
2 parents a6fe545 + 1066e0d commit 62dec00e4035722af6f4020dc19c9c4aefde4439 @danielctull committed Feb 20, 2011
View
3 DCTBlock.h
@@ -8,4 +8,5 @@
#import <Foundation/Foundation.h>
-typedef void (^DCTBlock) ();
+/** Typedef to a block. */
+typedef void (^DCTBlock) ();
View
2 DCTBlock.m
@@ -6,4 +6,4 @@
// Copyright 2010 Daniel Tull. All rights reserved.
//
-#import "DCTBlock.h"
+#import "DCTBlock.h"
View
2 DCTObservationInfo.h
@@ -54,4 +54,4 @@
@interface NSSet (DCTObservationInfo)
- (NSSet *)dct_observationInfosWithObject:(id)object keyPath:(NSString *)keyPath;
-@end
+@end
View
2 DCTObservationInfo.m
@@ -65,4 +65,4 @@ - (NSSet *)dct_observationInfosWithObject:(id)object keyPath:(NSString *)keyPath
}];
}
-@end
+@end
View
26 DCTQueue.h
@@ -36,45 +36,37 @@
#import <Foundation/Foundation.h>
-
+/**
+ Implementation of a queue data (first in, first out) structure.
+ */
@interface DCTQueue : NSObject {
NSMutableArray *queue;
}
-
-/** @name Standard queue operations
- @{
- */
-
-/** @brief The number of items in the queue.
+/** The number of items in the queue.
@return The number of items in the queue.
*/
- (NSUInteger)count;
-/** @brief Add an object to the end of the queue.
+/** Add an object to the end of the queue.
@param object The object to add.
*/
- (void)enqueue:(id)object;
-- (void)push:(id)object;
+//- (void)push:(id)object;
-/** @brief Remove the object at the front of the queue and return it.
+/** Remove the object at the front of the queue and return it.
@return The object at the front of the queue.
*/
- (id)dequeue;
-- (id)pop;
+//- (id)pop;
-/** @brief Return the object at the front of the queue without removing it from the queue.
+/** Return the object at the front of the queue without removing it from the queue.
@return The object at the front of the queue.
*/
- (id)front;
-/**
- @}
- */
-
-
@end
View
34 DCTStack.h
@@ -44,68 +44,52 @@
NSMutableArray *stack;
}
-/** @name Standard stack operations
- @{
- */
+/// @name Standard stack operations
-/** @brief The number of items on the stack.
+/** The number of items on the stack.
@return The number of items on the stack.
*/
- (NSUInteger)count;
-/** @brief Pushes the given object onto the top of the stack.
+/** Pushes the given object onto the top of the stack.
@param object The object to be pushed onto the stack.
*/
- (void)push:(id)object;
-/** @brief Removes the top object from the stack.
+/** Removes the top object from the stack.
@return The object that has just been popped off the top of the stack.
*/
- (id)pop;
-/** @brief Returns the top object without popping it from the stack.
+/** Returns the top object without popping it from the stack.
@return The top object on the stack.
*/
- (id)top;
-
-/**
- @}
- */
+/// @name Extra functionality
-- (id)topObject;
-
-/** @name Extra functionality
- @{
- */
-
-
-/** @brief Returns an NSArray of all the objects in the stack.
+/** Returns an NSArray of all the objects in the stack.
@return An array of all the objects in the stack.
*/
- (NSArray *)allObjects;
-/** @brief Pops the stack until it reaches the given object.
+/** Pops the stack until it reaches the given object.
@param object The object to pop to in the stack.
@return An array of all objects that have been removed from the stack.
*/
- (NSArray *)popToObject:(id)object;
-/** @brief Pops the stack until it has only one item left.
+/** Pops the stack until it has only one item left.
@return An array of all objects that have been removed from the stack.
*/
- (NSArray *)popToRootObject;
-/**
- @}
- */
-
@end
View
44 NSArray+DCTExtras.h
@@ -39,20 +39,62 @@
@interface NSArray (DCTExtras)
-/** @brief Returns whether or not the receiving array is empty.
+
+
+/** Returns whether or not the receiving array is empty.
@return A boolean indicating whether or not the receiving array is empty.
*/
- (BOOL)dct_isEmpty;
+
+
+/** Returns the first object in the array or nil if the receiver is empty.
+
+ @return The first object in the array or nil.
+ */
- (id)dct_firstObject;
+
+
+/** Returns an array containing only objects which are the kind of the given class.
+
+ @param aClass The class to check objects for.
+ @return Subarray containing only objects which are kind of the given class.
+ */
- (NSArray *)dct_subarrayWithObjectsOfClass:(Class)aClass;
+
+
+/** Looks in the receiver for an object of the given class and returns YES if one is found.
+
+ @param aClass The class to check objects for.
+ @return YES if receiver contains an object of the given class, NO otherwise.
+ */
- (BOOL)dct_containsObjectOfClass:(Class)aClass;
+
+
+/** Splits the receiver into sub-arrays of the given count.
+
+ If the receiver has 12 objects, and you give a count of 5 you will be returned an array
+ with 3 arrays inside, with counts of 5, 5 and 2. If you gave a count of 6, you would be
+ returned an array with 2 sub-arrays, both with a count of 6.
+
+ @param aCount The maximum length each of the subarrays should be.
+ @return An array of the sub-arrays.
+ */
- (NSArray *)dct_splitArrayIntoArraysWithCount:(NSInteger)aCount;
+
+
+/** Creates a sorted array of objects in the receiver, by putting the given key into a
+ sort descriptor array.
+
+ @param key The key to sort each of the objects with.
+ @param ascending Boolean to say whether the sorted array should be ascending or not (descending).
+ @return Sorted array.
+ */
- (NSArray *)dct_sortedArrayUsingKey:(NSString *)key ascending:(BOOL)ascending;
@end
View
56 NSDate+DCTDateComponents.h
@@ -42,97 +42,85 @@
*/
@interface NSDate (DCTDateComponents)
-/** @name Getting Gregorian date components
- @{
- */
+/// @name Getting Gregorian date components */
- (NSDateComponents *)dct_gregorianCalendarComponents;
-/**
- @}
- */
+/// Getting individual components
-/** @name Getting individual components
- @{
- */
-
-/** @brief The second component of the receiver.
+/** The second component of the receiver.
@return The second component of the receiver as an integer.
*/
- (NSInteger)dct_second;
-/** @brief The minute component of the receiver.
+/** The minute component of the receiver.
@return The minute component of the receiver as an integer.
*/
- (NSInteger)dct_minute;
-/** @brief The hour component of the receiver.
+/** The hour component of the receiver.
@return The hour component of the receiver as an integer.
*/
- (NSInteger)dct_hour;
-/** @brief The day component of the receiver.
+/** The day component of the receiver.
@return The day component of the receiver as an integer.
*/
- (NSInteger)dct_day;
-/** @brief The weekday component of the receiver.
+/** The weekday component of the receiver.
@return The weekday component of the receiver as an integer.
*/
- (NSInteger)dct_weekday;
-/** @brief The weekdayOrdinal component of the receiver.
+/** The weekdayOrdinal component of the receiver.
@return The weekdayOrdinal component of the receiver as an integer.
*/
- (NSInteger)dct_weekdayOrdinal;
-/** @brief The week component of the receiver.
+/** The week component of the receiver.
@return The week component of the receiver as an integer.
*/
- (NSInteger)dct_week;
-/** @brief The month component of the receiver.
+/** The month component of the receiver.
@return The month component of the receiver as an integer.
*/
- (NSInteger)dct_month;
-/** @brief The year component of the receiver.
+/** The year component of the receiver.
@return The year component of the receiver as an integer.
*/
- (NSInteger)dct_year;
-/** @brief The era component of the receiver.
+/** The era component of the receiver.
@return The era component of the receiver as an integer.
*/
- (NSInteger)dct_era;
-/**
- @}
- */
-/** @name Creating a date
- @{
- */
-/** @brief Creates a data with a year.
+/// @name Creating a date
+
+/** Creates a data with a year.
@param year The year of the date.
@return The newly created date.
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year;
-/** @brief Creates a data with a year and month.
+/** Creates a data with a year and month.
@param year The year of the date.
@param month The month of the date.
@@ -141,7 +129,7 @@
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year month:(NSInteger)month;
-/** @brief Creates a data with a year, month and day.
+/** Creates a data with a year, month and day.
@param year The year of the date.
@param month The month of the date.
@@ -151,7 +139,7 @@
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
-/** @brief Creates a data with a year, month, day and hour.
+/** Creates a data with a year, month, day and hour.
@param year The year of the date.
@param month The month of the date.
@@ -162,7 +150,7 @@
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour;
-/** @brief Creates a data with a year, month, day, hour and minute.
+/** Creates a data with a year, month, day, hour and minute.
@param year The year of the date.
@param month The month of the date.
@@ -174,7 +162,7 @@
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute;
-/** @brief Creates a data with a year, month, day, hour, minute and second.
+/** Creates a data with a year, month, day, hour, minute and second.
@param year The year of the date.
@param month The month of the date.
@@ -187,8 +175,4 @@
*/
+ (NSDate *)dct_dateWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;
-/**
- @}
- */
-
@end
View
16 NSError+DCTExtensions.h
@@ -36,15 +36,31 @@
#import <Foundation/Foundation.h>
+/** Convenience methods for creating NSErrors. */
@interface NSError (DCTExtensions)
+/** Convenience method for creating an NSError.
+
+ @param domain String to use as the domain.
+ @param code Integer to use as the error code.
+ @param localizedDescription String to use as the localized description.
+ @param localizedFailureReason String to use as the reason.
+ @param localizedRecoveryOptions Array of options.
+ @param localizedRecoverySuggestion String suggestion.
+ */
+ (id)dct_errorWithDomain:(NSString *)domain
code:(NSInteger)code
localizedDescription:(NSString *)localizedDescription
localizedFailureReason:(NSString *)localizedFailureReason
localizedRecoveryOptions:(NSArray *)localizedRecoveryOptions
localizedRecoverySuggestion:(NSString *)localizedRecoverySuggestion;
+/** Convenience method for creating an NSError.
+
+ @param domain String to use as the domain.
+ @param code Integer to use as the error code.
+ @param localizedDescription String to use as the localized description.
+ */
+ (id)dct_errorWithDomain:(NSString *)domain
code:(NSInteger)code
localizedDescription:(NSString *)localizedDescription;
View
12 NSMutableArray+DCTExtras.h
@@ -8,10 +8,20 @@
#import <Foundation/Foundation.h>
-
+/** Addtions to the NSMutableArray class.
+ */
@interface NSMutableArray (DCTExtras)
+/** Adds the objects from the given array if they aren't already in the receiver.
+
+ @param array Array of objects to add.
+ */
- (void)dct_addObjectsFromArrayIfNew:(NSArray *)array;
+
+/** Adds the given object if it isn't already in the receiver.
+
+ @param object The object to add.
+ */
- (void)dct_addObjectIfNew:(id)object;
@end
View
10 NSMutableSet+DCTExtras.h
@@ -9,8 +9,18 @@
#import <Foundation/Foundation.h>
#import "DCTBlock.h"
+/// Extra methods for NSMutableSet.
@interface NSMutableSet (DCTExtras)
+
+/** Block copies the given block before adding it.
+
+ A DCTBlock is defined in `DCTBlock.h` as the following, so you can pass any block you wish into this method.
+
+ `typedef void (^DCTBlock) ();`
+
+ @param block The block to add.
+ */
- (void)dct_addBlock:(DCTBlock)block;
@end
View
24 NSObject+DCTKVOExtras.h
@@ -38,9 +38,33 @@
typedef void (^DCTKeyValueChange) ();
+/** Helper methods to handle key-value coding calls.
+ */
@interface NSObject (DCTKVOExtras)
+
+/** Convenience method that calls willChangeValueForKey: and didChangeValueForKey: for the given key
+ either side of the change block.
+
+ DCTKeyValueChange is a block defined as:
+
+ `typedef void (^DCTKeyValueChange) ();`
+
+ @param key The key that is changed in the change block.
+ @param change The change block that performs the change.
+ */
- (void)dct_changeValueForKey:(NSString *)key withChange:(DCTKeyValueChange)change;
+
+/** Convenience method that calls willChangeValueForKey: and didChangeValueForKey: for each key
+ in the array of keys either side of the change block.
+
+ DCTKeyValueChange is a block defined as:
+
+ `typedef void (^DCTKeyValueChange) ();`
+
+ @param keys An array of keys that are changed in the change block.
+ @param change The change block that performs the change.
+ */
- (void)dct_changeValueForKeys:(NSArray *)keys withChange:(DCTKeyValueChange)change;
@end
View
39 NSObject+DCTPerformSelector.h
@@ -36,12 +36,51 @@
#import <Foundation/Foundation.h>
+/** Helper methods to handle checks before perfoming selectors.
+ */
@interface NSObject (DCTPerformSelector)
+/// @name Protocol Checking
+
+/** If the receiver conforms to the given protocol, dct_safePerformSelector: is called with the given selector.
+
+ @param selector The selector to perform.
+ @param protocol The protocol that the receiving object should conform to.
+
+ @return The return from dct_safePerformSelector: or nil if the object doesn't conform to the protocol.
+ */
- (id)dct_performSelector:(SEL)selector ifConformsToProtocol:(Protocol *)protocol;
+
+/** If the receiver conforms to the given protocol, dct_safePerformSelector:withObject: is called with the
+ given selector and object.
+
+ @param selector The selector to perform.
+ @param object The object to use.
+ @param protocol The protocol that the receiving object should conform to.
+
+ @return The return from dct_safePerformSelector:withObject: or nil if the object doesn't conform to the protocol.
+ */
- (id)dct_performSelector:(SEL)selector withObject:(id)object ifConformsToProtocol:(Protocol *)protocol;
+/// @name Selector Checking
+
+
+/** Checks to make sure the selector exists before calling performSelector: with the given selector.
+
+ @param selector The selector to perform.
+ @return The return from performSelector: or nil if the object doesn't conform to the protocol.
+ */
- (id)dct_safePerformSelector:(SEL)selector;
+
+
+/** Checks to make sure the selector exists before calling performSelector:withObject: with the given selector and object.
+
+ @param selector The selector to perform.
+ @param object The object to use.
+
+ @return The return from performWithSelector:withObject: or nil if the selector doesn't exist.
+ */
+
- (id)dct_safePerformSelector:(SEL)selector withObject:(id)object;
@end

0 comments on commit 62dec00

Please sign in to comment.