is an open-source library of standard data structures which can be used in any Objective-C program, for educational purposes or as a foundation for other data structures to build on. Data structures in this framework adopt Objective-C protocols that define the functionality of and API for interacting with any implementation thereof, regardless of its internals.
60 |
61 | Apple's extensive and flexible Cocoa frameworks include several collections classes that are highly optimized and amenable to many situations. However, sometimes an honest-to-goodness stack, queue, linked list, tree, etc. can greatly improve the clarity and comprehensibility of code. This framework provides Objective-C implementations of common data structures which are currently beyond the purview of Cocoa.
62 |
63 | The abstract data type protocols include:
64 | - CHDeque
65 | - CHHeap
66 | - CHLinkedList
67 | - CHQueue
68 | - CHSearchTree
69 | - CHSortedSet
70 | - CHStack
71 |
72 | The concrete child classes of NSMutableArray include:
73 | - CHCircularBuffer
74 | - CHCircularBufferDeque
75 | - CHCircularBufferQueue
76 | - CHCircularBufferStack
77 | - CHMutableArrayHeap
78 |
79 | The concrete child classes of NSMutableDictionary include:
80 | - CHMutableDictionary
81 | - CHBidirectionalDictionary
82 | - CHMultiDictionary
83 | - CHOrderedDictionary
84 | - CHSortedDictionary
85 |
86 | The concrete child classes of NSMutableSet include:
87 | - CHMutableSet
88 | - CHOrderedSet
89 |
90 | The code is written for Cocoa applications and does use some features of Objective-C 2.0, which is present in Mac OS X 10.5+ and all versions of iOS. Most of the code could be ported to other Objective-C environments (such as GNUStep) without too much trouble. However, such efforts would probably be better accomplished by forking this project rather than integrating with it, for several main reasons:
91 |
92 |
93 | - Supporting multiple environments increases code complexity, and consequently the effort required to test, maintain, and improve it.
94 | - Libraries that have bigger and slower binaries to accommodate all possible platforms don't help the mainstream developer.
95 | - Apple is the de facto custodian and strongest proponent of Objective-C, a trend which isn't likely to change soon.
96 |
97 |
98 | While certain implementations utilize straight C for their internals, this framework exposes fairly high-level APIs, and uses composition rather than inheritance wherever it makes sense. The framework was originally created as an exercise in writing Objective-C code and consisted mainly of ported Java code. In later revisions, performance has gained greater emphasis, but the primary motivation is to provide friendly, intuitive Objective-C interfaces for data structures, not to maximize speed at any cost, which sometimes happens with C++ and the STL. The algorithms should all be sound (i.e., you won't get O(n) performance where it should be O(log n) or O(1), etc.) and perform quite well in general. If your choice of data structure type and implementation are dependent on performance or memory usage, it would be wise to run the benchmarks from Xcode and choose based on the time and memory complexity for specific implementations.
99 |
100 | This framework is released under a variant of the ISC license, an extremely simple and permissive free software license (functionally equivalent to the MIT license and two-clause BSD license) approved by the Open Source Initiative (OSI) and recognized as GPL-compatible by the GNU Project. The license is included in every source file, and is reproduced in its entirety here:
101 |
102 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
103 |
104 | Earlier versions of this framework were released under a copyleft license, which are generally unfriendly towards commercial software development.
105 |
106 | If you would like to contribute to the library or let me know that you use it, please email me. I am very receptive to help, criticism, flames, whatever.
107 |
108 | — Quinn Taylor
109 |
110 |
111 |
112 | @todo Add support for NSSortDescriptor for comparator-style sorting. (Currently, all implementations use -compare: for sorting.)
113 |
114 | @todo Consider implementing "versionable" persistent data structures, wherein concurrent enumeration and modification are supported via tagged versions of the structure. (An example of this for red-black trees is an exercise for the reader in "Introduction to Algorithms, 2nd Edition" (ISBN: 9780262032933) in problem 13.1, pages 294-295.) The best candidates are probably queues, heaps, and search trees (sorted sets).
115 |
116 | @todo Look at adding @c -filterUsingPredicate: to all data structures. This would allow applying an NSPredicate and removing only objects that don't match. Also add copying variants (@c -filteredQueueUsingPredicate:, @c -filteredSortedSetUsingPredicate:, etc.) to avoid the overhead of a full copy before filtering.
117 |
118 | @todo Examine feasibility and utility of implementing key-value observing/coding/binding.
119 | */
120 |
--------------------------------------------------------------------------------
/Backlog Notes/Classes/thirdparty/CHDataStructures/include/CHOrderedSet.h:
--------------------------------------------------------------------------------
1 | /*
2 | CHDataStructures.framework -- CHOrderedSet.h
3 |
4 | Copyright (c) 2009-2010, Quinn Taylor
5 |
6 | This source code is released under the ISC License.
7 |
8 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
9 |
10 | The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
11 | */
12 |
13 | #import "CHMutableSet.h"
14 |
15 | /**
16 | @file CHOrderedSet.h
17 | A set which also maintains order of insertion, including manual reordering.
18 | */
19 |
20 | /**
21 | A set which also maintains order of insertion, including manual reordering.
22 |
23 | An ordered set is a composite data structure which combines a set and a list. It blends the uniqueness aspect of sets with the ability to recall the order in which items were added to the set. While this is possible with only a ordered set, the speedy test for membership is a set means that many basic operations (such as add, remove, and contains) that take linear time for a list can be accomplished in constant time (i.e. O(1) instead of O(n) complexity. Compared to these gains, the time overhead required for maintaining the list is negligible, although it does increase memory requirements.
24 |
25 | One of the most common implementations of an insertion-ordered set is Java's LinkedHashSet. This implementation wraps an NSMutableSet and a circular buffer to maintain insertion order. The API is designed to be as consistent as possible with that of NSSet and NSMutableSet.
26 |
27 | @see CHOrderedDictionary
28 |
29 | @todo Allow setting a maximum size, and either reject additions or evict the "oldest" item when the limit is reached? (Perhaps this would be better done by the user...)
30 | */
31 | @interface CHOrderedSet : CHMutableSet {
32 | id ordering; // A structure for maintaining ordering of the objects.
33 | }
34 |
35 | #pragma mark Querying Contents
36 | /** @name Querying Contents */
37 | // @{
38 |
39 | /**
40 | Returns an array of the objects in the set, in the order in which they were inserted.
41 |
42 | @return An array of the objects in the set, in the order in which they were inserted.
43 |
44 | @see anyObject
45 | @see objectEnumerator
46 | */
47 | - (NSArray*) allObjects;
48 |
49 | /**
50 | Returns the "oldest" member of the receiver.
51 |
52 | @return The "oldest" member of the receiver.
53 |
54 | @see addObject:
55 | @see anyObject
56 | @see lastObject
57 | @see removeFirstObject
58 | */
59 | - (id) firstObject;
60 |
61 | /**
62 | Returns the index of a given object based on insertion order.
63 |
64 | @param anObject The object to search for in the receiver.
65 | @return The index of @a anObject based on insertion order. If the object does not existsin the receiver, @c NSNotFound is returned.
66 |
67 | @see firstObject
68 | @see lastObject
69 | @see objectAtIndex:
70 | @see removeObjectAtIndex:
71 | */
72 | - (NSUInteger) indexOfObject:(id)anObject;
73 |
74 | /**
75 | Compares the receiving ordered set to another ordered set. Two ordered sets have equal contents if they each hold the same number of objects and objects at a given position in each ordered set satisfy the \link NSObject-p#isEqual: -isEqual:\endlink test.
76 |
77 | @param otherOrderedSet A ordered set.
78 | @return @c YES if the contents of @a otherOrderedSet are equal to the contents of the receiver, otherwise @c NO.
79 | */
80 | - (BOOL) isEqualToOrderedSet:(CHOrderedSet*)otherOrderedSet;
81 |
82 | /**
83 | Returns the "youngest" member of the receiver.
84 |
85 | @return The object in the array with the highest index value. If the array is empty, returns nil.
86 |
87 | @see addObject:
88 | @see anyObject
89 | @see firstObject
90 | @see removeLastObject
91 | */
92 | - (id) lastObject;
93 |
94 | /**
95 | Returns the value at the specified index.
96 |
97 | @param index The insertion-order index of the value to retrieve.
98 | @return The value at the specified index, based on insertion order.
99 |
100 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
101 |
102 | @see indexOfObject:
103 | @see objectsAtIndexes:
104 | @see removeObjectAtIndex:
105 | */
106 | - (id) objectAtIndex:(NSUInteger)index;
107 |
108 | /**
109 | Returns an enumerator object that lets you access each object in the receiver by insertion order.
110 |
111 | @return An enumerator object that lets you access each object in the receiver by insertion order.
112 |
113 | @warning Modifying a collection while it is being enumerated is unsafe, and may cause a mutation exception to be raised.
114 |
115 | If you need to modify the entries concurrently, you can enumerate over a "snapshot" of the set's values obtained from #allObjects.
116 |
117 | @see allObjects
118 | */
119 | - (NSEnumerator*) objectEnumerator;
120 |
121 | /**
122 | Returns an array containing the objects in the receiver at the indexes specified by a given index set.
123 |
124 | @param indexes A set of positions corresponding to objects to retrieve from the receiver.
125 | @return A new array containing the objects in the receiver specified by @a indexes.
126 |
127 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
128 | @throw NSInvalidArgumentException if @a indexes is @c nil.
129 |
130 | @attention To retrieve objects in a given NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
131 |
132 | @see allObjects
133 | @see objectAtIndex:
134 | @see removeObjectsAtIndexes:
135 | */
136 | - (NSArray*) objectsAtIndexes:(NSIndexSet*)indexes;
137 |
138 | /**
139 | Returns an ordered dictionary containing the objects in the receiver at the indexes specified by a given index set.
140 |
141 | @param indexes A set of indexes for keys to retrieve from the receiver.
142 | @return An array containing the objects in the receiver at the indexes specified by @a indexes.
143 |
144 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
145 | @throw NSInvalidArgumentException if @a indexes is @c nil.
146 |
147 | @attention To retrieve entries in a given NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter.
148 | */
149 | - (CHOrderedSet*) orderedSetWithObjectsAtIndexes:(NSIndexSet*)indexes;
150 |
151 | // @}
152 | #pragma mark Modifying Contents
153 | /** @name Modifying Contents */
154 | // @{
155 |
156 | /**
157 | Adds a given object to the receiver at a given index. If the receiver already contains an equivalent object, it is replaced with @a anObject.
158 |
159 | @param anObject The object to add to the receiver.
160 | @param index The index at which @a anObject should be inserted.
161 |
162 | @see addObject:
163 | @see indexOfObject:
164 | @see objectAtIndex:
165 | */
166 | - (void) insertObject:(id)anObject atIndex:(NSUInteger)index;
167 |
168 | /**
169 | Exchange the objects in the receiver at given indexes.
170 |
171 | @param idx1 The index of the object to replace with the object at @a idx2.
172 | @param idx2 The index of the object to replace with the object at @a idx1.
173 |
174 | @throw NSRangeException if @a idx1 or @a idx2 exceeds the bounds of the receiver.
175 |
176 | @see indexOfObject:
177 | @see insertObject:atIndex:
178 | @see objectAtIndex:
179 | */
180 | - (void) exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
181 |
182 | /**
183 | Remove the "oldest" member of the receiver.
184 |
185 | @see firstObject
186 | @see removeAllObjects
187 | @see removeObject:
188 | @see removeObjectAtIndex:
189 | */
190 | - (void) removeFirstObject;
191 |
192 | /**
193 | Remove the "youngest" member of the receiver.
194 |
195 | @see lastObject
196 | @see removeAllObjects
197 | @see removeObject:
198 | @see removeObjectAtIndex:
199 | */
200 | - (void) removeLastObject;
201 |
202 | /**
203 | Remove the object at a given index from the receiver.
204 |
205 | @param index The index of the object to remove.
206 |
207 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
208 |
209 | @see minusSet:
210 | @see objectAtIndex:
211 | @see removeAllObjects
212 | @see removeFirstObject
213 | @see removeLastObject
214 | @see removeObject:
215 | @see removeObjectsAtIndexes:
216 | */
217 | - (void) removeObjectAtIndex:(NSUInteger)index;
218 |
219 | /**
220 | Remove the objects at the specified indexes from the receiver.
221 | @param indexes A set of positions corresponding to objects to remove from the receiver.
222 |
223 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
224 | @throw NSInvalidArgumentException if @a indexes is @c nil.
225 |
226 | @attention To remove objects in a given @c NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
227 |
228 | @see objectsAtIndexes:
229 | @see removeAllObjects
230 | @see removeObjectAtIndex:
231 | */
232 | - (void) removeObjectsAtIndexes:(NSIndexSet*)indexes;
233 |
234 | // @}
235 | @end
236 |
--------------------------------------------------------------------------------
/Backlog Notes/Classes/thirdparty/CHDataStructures/include/Util.h:
--------------------------------------------------------------------------------
1 | /*
2 | CHDataStructures.framework -- Util.h
3 |
4 | Copyright (c) 2008-2010, Quinn Taylor
5 |
6 | This source code is released under the ISC License.
7 |
8 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
9 |
10 | The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
11 | */
12 |
13 | #import
14 |
15 | /**
16 | @file Util.h
17 | A group of utility C functions for simplifying common exceptions and logging.
18 | */
19 |
20 | /** Macro for reducing visibility of symbol names not indended to be exported. */
21 | #define HIDDEN __attribute__((visibility("hidden")))
22 |
23 | /** Macro for designating symbols as being unused to suppress compile warnings. */
24 | #define UNUSED __attribute__((unused))
25 |
26 | #pragma mark -
27 |
28 | // NSInteger/NSUInteger are new in Leopard; define if on an earlier OS version.
29 | #ifndef NSINTEGER_DEFINED
30 | #if __LP64__ || NS_BUILD_32_LIKE_64
31 | typedef long NSInteger;
32 | typedef unsigned long NSUInteger;
33 | #else
34 | typedef int NSInteger;
35 | typedef unsigned int NSUInteger;
36 | #endif
37 |
38 | #define NSIntegerMax LONG_MAX
39 | #define NSIntegerMin LONG_MIN
40 | #define NSUIntegerMax ULONG_MAX
41 |
42 | #define NSINTEGER_DEFINED 1
43 | #endif
44 |
45 | #pragma mark -
46 |
47 | // For iOS, define enum and dummy functions used for Garbage Collection.
48 | #if (TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || !TARGET_OS_MAC)
49 |
50 | enum {
51 | NSScannedOption = (1UL << 0),
52 | NSCollectorDisabledOption = (1UL << 1),
53 | };
54 |
55 | void* __strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
56 |
57 | void* __strong NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options);
58 |
59 | #define objc_memmove_collectable memmove
60 |
61 | #else
62 |
63 | // This is declared in , but importing the header is overkill.
64 | HIDDEN void* objc_memmove_collectable(void *dst, const void *src, size_t size);
65 |
66 | #endif
67 |
68 | #pragma mark -
69 |
70 | /** Global variable to simplify checking if garbage collection is enabled. */
71 | OBJC_EXPORT BOOL kCHGarbageCollectionNotEnabled;
72 |
73 | /** Global variable to store the size of a pointer only once. */
74 | HIDDEN size_t kCHPointerSize;
75 |
76 | /**
77 | Simple function for checking object equality, to be used as a function pointer.
78 |
79 | @param o1 The first object to be compared.
80 | @param o2 The second object to be compared.
81 | @return [o1 isEqual:o2]
82 | */
83 | HIDDEN BOOL objectsAreEqual(id o1, id o2);
84 |
85 | /**
86 | Simple function for checking object identity, to be used as a function pointer.
87 |
88 | @param o1 The first object to be compared.
89 | @param o2 The second object to be compared.
90 | @return o1 == o2
91 | */
92 | HIDDEN BOOL objectsAreIdentical(id o1, id o2);
93 |
94 | /**
95 | Determine whether two collections enumerate the equivalent objects in the same order.
96 |
97 | @param collection1 The first collection to be compared.
98 | @param collection2 The second collection to be compared.
99 | @return Whether the collections are equivalent.
100 |
101 | @throw NSInvalidArgumentException if one of both of the arguments do not respond to the @c -count or @c -objectEnumerator selectors.
102 | */
103 | OBJC_EXPORT BOOL collectionsAreEqual(id collection1, id collection2);
104 |
105 | /**
106 | Generate a hash for a collection based on the count and up to two objects. If objects are provided, the result of their -hash method will be used.
107 |
108 | @param count The number of objects in the collection.
109 | @param o1 The first object to include in the hash.
110 | @param o2 The second object to include in the hash.
111 | @return An unsigned integer that can be used as a table address in a hash table structure.
112 | */
113 | HIDDEN NSUInteger hashOfCountAndObjects(NSUInteger count, id o1, id o2);
114 |
115 | #pragma mark -
116 |
117 | /**
118 | Convenience function for raising an exception for an invalid range (index).
119 |
120 | Currently, there is no support for calling this function from a C function.
121 |
122 | @param aClass The class object for the originator of the exception. Callers should pass the result of [self class] for this parameter.
123 | @param method The method selector where the problem originated. Callers should pass @c _cmd for this parameter.
124 | @param index The offending index passed to the receiver.
125 | @param elements The number of elements present in the receiver.
126 |
127 | @throw NSRangeException
128 |
129 | @see \link NSException#raise:format: +[NSException raise:format:]\endlink
130 | */
131 | OBJC_EXPORT void CHIndexOutOfRangeException(Class aClass, SEL method,
132 | NSUInteger index, NSUInteger elements);
133 |
134 | /**
135 | Convenience function for raising an exception on an invalid argument.
136 |
137 | Currently, there is no support for calling this function from a C function.
138 |
139 | @param aClass The class object for the originator of the exception. Callers should pass the result of [self class] for this parameter.
140 | @param method The method selector where the problem originated. Callers should pass @c _cmd for this parameter.
141 | @param str An NSString describing the offending invalid argument.
142 |
143 | @throw NSInvalidArgumentException
144 |
145 | @see \link NSException#raise:format: +[NSException raise:format:]\endlink
146 | */
147 | OBJC_EXPORT void CHInvalidArgumentException(Class aClass, SEL method, NSString *str);
148 |
149 | /**
150 | Convenience function for raising an exception on an invalid nil object argument.
151 |
152 | Currently, there is no support for calling this function from a C function.
153 |
154 | @param aClass The class object for the originator of the exception. Callers should pass the result of [self class] for this parameter.
155 | @param method The method selector where the problem originated. Callers should pass @c _cmd for this parameter.
156 |
157 | @throw NSInvalidArgumentException
158 |
159 | @see CHInvalidArgumentException()
160 | */
161 | OBJC_EXPORT void CHNilArgumentException(Class aClass, SEL method);
162 |
163 | /**
164 | Convenience function for raising an exception when a collection is mutated.
165 |
166 | Currently, there is no support for calling this function from a C function.
167 |
168 | @param aClass The class object for the originator of the exception. Callers should pass the result of [self class] for this parameter.
169 | @param method The method selector where the problem originated. Callers should pass @c _cmd for this parameter.
170 |
171 | @throw NSGenericException
172 |
173 | @see \link NSException#raise:format: +[NSException raise:format:]\endlink
174 | */
175 | OBJC_EXPORT void CHMutatedCollectionException(Class aClass, SEL method);
176 |
177 | /**
178 | Convenience function for raising an exception for un-implemented functionality.
179 |
180 | Currently, there is no support for calling this function from a C function.
181 |
182 | @param aClass The class object for the originator of the exception. Callers should pass the result of [self class] for this parameter.
183 | @param method The method selector where the problem originated. Callers should pass @c _cmd for this parameter.
184 |
185 | @throw NSInternalInconsistencyException
186 |
187 | @see \link NSException#raise:format: +[NSException raise:format:]\endlink
188 | */
189 | OBJC_EXPORT void CHUnsupportedOperationException(Class aClass, SEL method);
190 |
191 | /**
192 | Provides a more terse alternative to NSLog() which accepts the same parameters. The output is made shorter by excluding the date stamp and process information which NSLog prints before the actual specified output.
193 |
194 | @param format A format string, which must not be nil.
195 | @param ... A comma-separated list of arguments to substitute into @a format.
196 |
197 | Read Formatting String Objects and String Format Specifiers on this webpage for details about using format strings. Look for examples that use @c NSLog() since the parameters and syntax are idential.
198 | */
199 | OBJC_EXPORT void CHQuietLog(NSString *format, ...);
200 |
201 | /**
202 | A macro for including the source file and line number where a log occurred.
203 |
204 | @param format A format string, which must not be nil.
205 | @param ... A comma-separated list of arguments to substitute into @a format.
206 |
207 | This is defined as a compiler macro so it can automatically fill in the file name and line number where the call was made. After printing these values in brackets, this macro calls #CHQuietLog with @a format and any other arguments supplied afterward.
208 |
209 | @see CHQuietLog
210 | */
211 | #ifndef CHLocationLog
212 | #define CHLocationLog(format,...) \
213 | { \
214 | NSString *file = [[NSString alloc] initWithUTF8String:__FILE__]; \
215 | printf("[%s:%d] ", [[file lastPathComponent] UTF8String], __LINE__); \
216 | [file release]; \
217 | CHQuietLog((format),##__VA_ARGS__); \
218 | }
219 | #endif
220 |
--------------------------------------------------------------------------------
/Backlog Notes/Classes/AddNoteViewController.m:
--------------------------------------------------------------------------------
1 |
2 | #import "AddNoteViewController.h"
3 | #import "ChecklistItem.h"
4 |
5 | #define emptyNoteAlertViewsTag 0
6 |
7 | @interface AddNoteViewController ()
8 |
9 | @end
10 |
11 |
12 |
13 | @implementation AddNoteViewController {
14 |
15 | NSString *notes;
16 | BOOL shouldRemind;
17 | NSDate *dueDate;
18 | }
19 |
20 |
21 |
22 | ///synthesize properties
23 | @synthesize notesField, delegate, itemToEdit, dueDateLabel, activityViewController;
24 |
25 |
26 |
27 | ///we display current date and time when we present the addnotevewcontroller to user
28 | - (id)initWithCoder:(NSCoder *)aDecoder
29 | {
30 | if ((self = [super initWithCoder:aDecoder])) {
31 | notes = @"";
32 | shouldRemind = YES;
33 | dueDate = [NSDate date];
34 | }
35 | return self;
36 | }
37 |
38 |
39 |
40 | /// NSdate formetter to format date and update the label when user picked different date
41 | - (void)updateDueDateLabel
42 | {
43 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
44 | [formatter setDateStyle:NSDateFormatterShortStyle];
45 | [formatter setTimeStyle:NSDateFormatterShortStyle];
46 | self.dueDateLabel.text = [formatter stringFromDate:dueDate];
47 | }
48 |
49 |
50 |
51 |
52 | - (void)viewDidLoad
53 | {
54 | [super viewDidLoad];
55 |
56 | ///wecreate
57 | UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
58 | initWithBarButtonSystemItem:UIBarButtonSystemItemDone
59 | target:self
60 | action:@selector(done)];
61 |
62 | UIBarButtonItem *shareButton = [[UIBarButtonItem alloc]
63 | initWithBarButtonSystemItem:UIBarButtonSystemItemAction
64 | target:self
65 | action:@selector(shareButtonClicked:)];
66 |
67 |
68 | self.navigationItem.rightBarButtonItems =
69 | [NSArray arrayWithObjects:doneButton, shareButton, nil];
70 |
71 |
72 |
73 | ///we check whether it is editing mode or adding mode, then set the title and fields appropriately.
74 |
75 | if (self.itemToEdit != nil) {
76 | self.title = @"Edit Note";
77 | } else
78 |
79 | self.title = @"Add Note";
80 | self.notesField.text = notes;
81 |
82 |
83 | [self updateDueDateLabel];
84 | shareButton.enabled = YES;
85 |
86 |
87 | // Sets the TextView delegate
88 | self.notesField.delegate = self;
89 |
90 |
91 |
92 |
93 | [self customizeAppearance];
94 |
95 | }
96 |
97 |
98 |
99 | - (void)viewWillAppear:(BOOL)animated
100 | {
101 | [super viewWillAppear:animated];
102 |
103 | if (self.title != NSLocalizedString(@"Edit Note", nil)) {
104 | [self.notesField becomeFirstResponder];
105 | [self.notesField resignFirstResponder];
106 | // [self.notesField becomeFirstResponder];
107 |
108 | }else
109 | [self.notesField resignFirstResponder];
110 | }
111 |
112 |
113 |
114 |
115 |
116 | /// method to call addItemViewControllerDidCancel method when cancel button pressed
117 |
118 | - (IBAction)cancel
119 | {
120 | [self.delegate addItemViewControllerDidCancel:self];
121 | }
122 |
123 |
124 | /// method to call didFinishAddingItem method when Done button pressed
125 |
126 |
127 | - (IBAction)done
128 | {
129 |
130 | if ([self.notesField.text isEqualToString:@" "] || [self.notesField.text isEqualToString:@""] || [self.notesField.text isEqualToString:nil])
131 | {
132 |
133 | UIAlertView* message = [[UIAlertView alloc]
134 | initWithTitle: @"Empty !!!"
135 | message: @"Note is empty. Click OK to write again, or Cancel to dismiss."
136 | delegate: self
137 | cancelButtonTitle: @"Cancel"
138 | otherButtonTitles: @"OK", nil];
139 |
140 | message.tag = emptyNoteAlertViewsTag;
141 | [message show];
142 |
143 | }
144 | else
145 | {
146 | if (self.itemToEdit == nil) {
147 | ChecklistItem *item = [[ChecklistItem alloc] init];
148 |
149 | item.notes = self.notesField.text;
150 | item.shouldRemind = YES;
151 | item.dueDate = dueDate;
152 |
153 | // Shows the notification on the given date
154 | // [item scheduleNotification];
155 |
156 | [self.delegate addItemViewController:self didFinishAddingItem:item];
157 | } else {
158 | self.itemToEdit.notes = self.notesField.text;
159 | self.itemToEdit.shouldRemind = YES;
160 | self.itemToEdit.dueDate = dueDate;
161 |
162 | // Shows the notification on the given date
163 | // [self.itemToEdit scheduleNotification];
164 |
165 | [self.delegate addItemViewController:self didFinishEditingItem:self.itemToEdit];
166 | }
167 | }
168 |
169 |
170 | }
171 |
172 |
173 |
174 |
175 | ///optionally we can dismiss keyboard if the user starts to scroll the tableview
176 |
177 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
178 | {
179 | [self.notesField resignFirstResponder];
180 |
181 | }
182 |
183 |
184 |
185 | - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
186 |
187 | if (indexPath.section == 0) {
188 | cell.backgroundColor = TableCellBackgroundColor;
189 |
190 |
191 | }else{
192 |
193 | }
194 |
195 | }
196 |
197 |
198 | ///to prevent the uitableview cell turns blue when user taps on it
199 |
200 | - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
201 | {
202 | if (indexPath.row == 0) {
203 |
204 | return indexPath;
205 | } else {
206 | return nil;
207 | }
208 | }
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 | - (void)didReceiveMemoryWarning
217 | {
218 | [super didReceiveMemoryWarning];
219 |
220 | // Dispose of any resources that can be recreated.
221 | }
222 |
223 | ///release te memory by setting nil to these fields as we no loner need them
224 |
225 | - (void)viewDidUnload
226 | {
227 | [self setNotesField:nil];
228 | [self setDueDateLabel:nil];
229 | [super viewDidUnload];
230 | }
231 |
232 |
233 | ///we present stored item if the user editing an item
234 |
235 | - (void)setItemToEdit:(ChecklistItem *)newItem
236 | {
237 | if (itemToEdit != newItem) {
238 | itemToEdit = newItem;
239 | notes = itemToEdit.notes;
240 | shouldRemind = itemToEdit.shouldRemind;
241 | dueDate = itemToEdit.dueDate;
242 | }
243 | }
244 |
245 |
246 |
247 | #pragma mark - Table view data source
248 |
249 |
250 |
251 | ///we use prepare for segue method to display date picker controller
252 |
253 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
254 | {
255 |
256 | }
257 |
258 |
259 |
260 |
261 | -(IBAction) shareButtonClicked:(id)sender
262 | {
263 |
264 | NSString *emailBody = notesField.text;
265 |
266 | self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[emailBody] applicationActivities:nil];
267 |
268 | [self presentViewController:self.activityViewController animated:YES completion:nil];
269 |
270 |
271 | }
272 |
273 |
274 |
275 |
276 | #pragma mark - AlertView data source
277 |
278 | - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
279 |
280 | if (alertView.tag == emptyNoteAlertViewsTag)
281 | {
282 | if (buttonIndex == alertView.cancelButtonIndex) {
283 | // Cancel was tapped
284 | NSLog(@"Cancel was tapped");
285 |
286 | [self dismissViewControllerAnimated:YES completion:nil];
287 |
288 | }
289 | else if (buttonIndex == alertView.firstOtherButtonIndex)
290 | {
291 | // The other button was tapped
292 | NSLog(@"OK button was tapped");
293 | }
294 | }
295 | }
296 |
297 |
298 | #pragma mark - TextView data source
299 |
300 | - (void)textViewDidBeginEditing:(UITextView *)textView
301 | {
302 | NSLog(@"textViewDidBeginEditing...");
303 | // self.notesField.frame.origin.y = self.navigationController.navigationBar.frame.origin.y + self.dueDateLabel.frame.origin.y;
304 |
305 | // [self.notesField setFrame:CGRectMake(0, (self.navigationController.navigationBar.frame.origin.y + self.dueDateLabel.frame.origin.y), 320.0, 500)];
306 | }
307 |
308 | - (BOOL)textViewShouldBeginEditing:(UITextView *)textView
309 | {
310 | return YES;
311 | }
312 |
313 |
314 |
315 |
316 | -(void)customizeAppearance
317 | {
318 | self.navigationController.navigationBar.barTintColor = NavBarBackgroundColor;
319 | self.navigationController.navigationBar.translucent = NO;
320 |
321 | [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName :TableSectionHeaderTextColorYellow}];
322 |
323 |
324 |
325 | // Create the colors
326 | UIColor *lightOp = backgroundColorGradientTop;
327 | UIColor *darkOp = backgroundColorGradientBottom;
328 |
329 |
330 | // Create the gradient
331 | CAGradientLayer *gradient = [CAGradientLayer layer];
332 |
333 | // Set colors
334 | gradient.colors = [NSArray arrayWithObjects:
335 | (id)lightOp.CGColor,
336 | (id)darkOp.CGColor,
337 | nil];
338 |
339 | // Set bounds
340 | gradient.frame = self.view.bounds;
341 |
342 |
343 | UIImage *gradientImage = [self imageFromLayer:gradient];
344 | UIImage *worldBGImage = [UIImage imageNamed:@"blue-background.png"];
345 |
346 |
347 | CGSize size = CGSizeMake(gradientImage.size.width, gradientImage.size.height);
348 | UIGraphicsBeginImageContext(size);
349 |
350 | [worldBGImage drawInRect:CGRectMake(0,0,size.width, size.height)];
351 | [gradientImage drawInRect:CGRectMake(0,0,size.width, size.height)];
352 | // [worldBGImage drawInRect:CGRectMake(0,0,size.width, size.height)];
353 |
354 | UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
355 |
356 | UIGraphicsEndImageContext();
357 |
358 |
359 | self.tableView.backgroundView = [[UIImageView alloc] initWithImage:finalImage];
360 |
361 | // [notesField setBackgroundColor:[UIColor clearColor]];
362 | [notesField setBackgroundColor:TableCellBackgroundColor];
363 | }
364 |
365 | - (UIImage *)imageFromLayer:(CALayer *)layer
366 | {
367 | UIGraphicsBeginImageContext([layer frame].size);
368 |
369 | [layer renderInContext:UIGraphicsGetCurrentContext()];
370 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
371 |
372 | UIGraphicsEndImageContext();
373 |
374 | return outputImage;
375 | }
376 |
377 |
378 |
379 |
380 | @end
381 |
--------------------------------------------------------------------------------
/Backlog Notes/Classes/thirdparty/CHDataStructures/include/CHStack.h:
--------------------------------------------------------------------------------
1 | /*
2 | CHDataStructures.framework -- CHStack.h
3 |
4 | Copyright (c) 2008-2010, Quinn Taylor
5 | Copyright (c) 2002, Phillip Morelock
6 |
7 | This source code is released under the ISC License.
8 |
9 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
10 |
11 | The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
12 | */
13 |
14 | #import "Util.h"
15 |
16 | /**
17 | @file CHStack.h
18 |
19 | A stack protocol with methods for LIFO ("Last In, First Out") operations.
20 | */
21 |
22 | /**
23 | A stack protocol with methods for LIFO ("Last In, First Out") operations.
24 |
25 | A stack is commonly compared to a stack of plates. Objects may be added in any order (\link #pushObject: -pushObject:\endlink) and the most recently added object may be removed (\link #popObject -popObject\endlink) or returned without removing it (\link #topObject -topObject\endlink).
26 |
27 | @see CHDeque
28 | @see CHQueue
29 | */
30 | @protocol CHStack
31 |
32 | /**
33 | Initialize a stack with no objects.
34 |
35 | @return An initialized stack that contains no objects.
36 |
37 | @see initWithArray:
38 | */
39 | - (id) init;
40 |
41 | /**
42 | Initialize a stack with the contents of an array. Objects are pushed on the stack in the order they occur in the array.
43 |
44 | @param anArray An array containing objects with which to populate a new stack.
45 | @return An initialized stack that contains the objects in @a anArray.
46 | */
47 | - (id) initWithArray:(NSArray*)anArray;
48 |
49 | #pragma mark Querying Contents
50 | /** @name Querying Contents */
51 | // @{
52 |
53 | /**
54 | Returns an array of the objects in this stack, ordered from top to bottom.
55 |
56 | @return An array of the objects in this stack. If the stack is empty, the array is also empty.
57 |
58 | @see count
59 | @see objectEnumerator
60 | @see removeAllObjects
61 | */
62 | - (NSArray*) allObjects;
63 |
64 | /**
65 | Determine whether the receiver contains a given object, matched using \link NSObject-p#isEqual: -isEqual:\endlink.
66 |
67 | @param anObject The object to test for membership in the receiver.
68 | @return @c YES if the receiver contains @a anObject (as determined by \link NSObject-p#isEqual: -isEqual:\endlink), @c NO if @a anObject is @c nil or not present.
69 |
70 | @see containsObjectIdenticalTo:
71 | @see removeObject:
72 | */
73 | - (BOOL) containsObject:(id)anObject;
74 |
75 | /**
76 | Determine whether the receiver contains a given object, matched using the == operator.
77 |
78 | @param anObject The object to test for membership in the receiver.
79 | @return @c YES if the receiver contains @a anObject (as determined by the == operator), @c NO if @a anObject is @c nil or not present.
80 |
81 | @see containsObject:
82 | @see removeObjectIdenticalTo:
83 | */
84 | - (BOOL) containsObjectIdenticalTo:(id)anObject;
85 |
86 | /**
87 | Returns the number of objects currently on the stack.
88 |
89 | @return The number of objects currently on the stack.
90 |
91 | @see allObjects
92 | */
93 | - (NSUInteger) count;
94 |
95 | /**
96 | Returns the lowest index of a given object, matched using @c isEqual:.
97 |
98 | @param anObject The object to search for in the receiver.
99 | @return The index of the first object which is equal to @a anObject. If none of the objects in the receiver match @a anObject, returns @c NSNotFound.
100 |
101 | @see indexOfObjectIdenticalTo:
102 | @see objectAtIndex:
103 | @see removeObjectAtIndex:
104 | */
105 | - (NSUInteger) indexOfObject:(id)anObject;
106 |
107 | /**
108 | Returns the lowest index of a given object, matched using the == operator.
109 |
110 | @param anObject The object to be matched and located in the receiver.
111 | @return The index of the first object which is equal to @a anObject. If none of the objects in the receiver match @a anObject, returns @c NSNotFound.
112 |
113 | @see indexOfObject:
114 | @see objectAtIndex:
115 | @see removeObjectAtIndex:
116 | */
117 | - (NSUInteger) indexOfObjectIdenticalTo:(id)anObject;
118 |
119 | /**
120 | Compares the receiving stack to another stack. Two stacks have equal contents if they each hold the same number of objects and objects at a given position in each stack satisfy the \link NSObject-p#isEqual: -isEqual:\endlink test.
121 |
122 | @param otherStack A stack.
123 | @return @c YES if the contents of @a otherStack are equal to the contents of the receiver, otherwise @c NO.
124 | */
125 | - (BOOL) isEqualToStack:(id)otherStack;
126 |
127 | /**
128 | Returns the object located at @a index in the receiver.
129 |
130 | @param index An index from which to retrieve an object.
131 | @return The object located at @a index.
132 |
133 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
134 |
135 | @see indexOfObject:
136 | @see indexOfObjectIdenticalTo:
137 | @see removeObjectAtIndex:
138 | */
139 | - (id) objectAtIndex:(NSUInteger)index;
140 |
141 | /**
142 | Returns an enumerator that accesses each object in the stack from top to bottom.
143 |
144 | @return An enumerator that accesses each object in the stack from top to bottom. The enumerator returned is never @c nil; if the stack is empty, the enumerator will always return @c nil for \link NSEnumerator#nextObject -nextObject\endlink and an empty array for \link NSEnumerator#allObjects -allObjects\endlink.
145 |
146 | @attention The enumerator retains the collection. Once all objects in the enumerator have been consumed, the collection is released.
147 | @warning Modifying a collection while it is being enumerated is unsafe, and may cause a mutation exception to be raised.
148 |
149 | @see allObjects
150 | */
151 | - (NSEnumerator*) objectEnumerator;
152 |
153 | /**
154 | Returns an array containing the objects in the receiver at the indexes specified by a given index set.
155 |
156 | @param indexes A set of positions corresponding to objects to retrieve from the receiver.
157 | @return A new array containing the objects in the receiver specified by @a indexes.
158 |
159 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
160 | @throw NSInvalidArgumentException if @a indexes is @c nil.
161 |
162 | @attention To retrieve objects in a given NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
163 |
164 | @see allObjects
165 | @see objectAtIndex:
166 | @see removeObjectsAtIndexes:
167 | */
168 | - (NSArray*) objectsAtIndexes:(NSIndexSet*)indexes;
169 |
170 | /**
171 | Returns the object on the top of the stack without removing it.
172 |
173 | @return The topmost object from the stack.
174 |
175 | @see popObject
176 | @see pushObject:
177 | */
178 | - (id) topObject;
179 |
180 | // @}
181 | #pragma mark Modifying Contents
182 | /** @name Modifying Contents */
183 | // @{
184 |
185 | /**
186 | Exchange the objects in the receiver at given indexes.
187 |
188 | @param idx1 The index of the object to replace with the object at @a idx2.
189 | @param idx2 The index of the object to replace with the object at @a idx1.
190 |
191 | @throw NSRangeException if @a idx1 or @a idx2 exceeds the bounds of the receiver.
192 |
193 | @see indexOfObject:
194 | @see objectAtIndex:
195 | */
196 | - (void) exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
197 |
198 | /**
199 | Remove the topmost object on the stack; no effect if the stack is already empty.
200 |
201 | @see pushObject:
202 | @see removeObject:
203 | @see topObject
204 | */
205 | - (void) popObject;
206 |
207 | /**
208 | Add an object to the top of the stack.
209 |
210 | @param anObject The object to add to the top of the stack.
211 |
212 | @throw NSInvalidArgumentException if @a anObject is @c nil.
213 |
214 | @see popObject
215 | @see topObject
216 | */
217 | - (void) pushObject:(id)anObject;
218 |
219 | /**
220 | Empty the receiver of all of its members.
221 |
222 | @see allObjects
223 | @see popObject
224 | @see removeObject:
225 | @see removeObjectIdenticalTo:
226 | */
227 | - (void) removeAllObjects;
228 |
229 | /**
230 | Remove @b all occurrences of @a anObject, matched using @c isEqual:.
231 |
232 | @param anObject The object to be removed from the stack.
233 |
234 | If the stack is empty, @a anObject is @c nil, or no object matching @a anObject is found, there is no effect, aside from the possible overhead of searching the contents.
235 |
236 | @see containsObject:
237 | @see removeObjectIdenticalTo:
238 | */
239 | - (void) removeObject:(id)anObject;
240 |
241 | /**
242 | Remove the object at a given index from the receiver.
243 |
244 | @param index The index of the object to remove.
245 |
246 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
247 |
248 | @see indexOfObject:
249 | @see indexOfObjectIdenticalTo:
250 | @see objectAtIndex:
251 | */
252 | - (void) removeObjectAtIndex:(NSUInteger)index;
253 |
254 | /**
255 | Remove @b all occurrences of @a anObject, matched using the == operator.
256 |
257 | @param anObject The object to be removed from the stack.
258 |
259 | If the stack is empty, @a anObject is @c nil, or no object matching @a anObject is found, there is no effect, aside from the possible overhead of searching the contents.
260 |
261 | @see containsObjectIdenticalTo:
262 | @see removeObject:
263 | */
264 | - (void) removeObjectIdenticalTo:(id)anObject;
265 |
266 | /**
267 | Remove the objects at the specified indexes from the receiver. Indexes of elements beyond the first specified index will decrease.
268 | @param indexes A set of positions corresponding to objects to remove from the receiver.
269 |
270 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
271 | @throw NSInvalidArgumentException if @a indexes is @c nil.
272 |
273 | @attention To remove objects in a given @c NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
274 |
275 | @see objectsAtIndexes:
276 | @see removeAllObjects
277 | @see removeObjectAtIndex:
278 | */
279 | - (void) removeObjectsAtIndexes:(NSIndexSet*)indexes;
280 |
281 | /**
282 | Replaces the object at a given index with a given object.
283 |
284 | @param index The index of the object to be replaced.
285 | @param anObject The object with which to replace the object at @a index in the receiver.
286 |
287 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
288 | @throw NSInvalidArgumentException if @a anObject is @c nil.
289 | */
290 | - (void) replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
291 |
292 | // @}
293 | @end
294 |
--------------------------------------------------------------------------------
/Backlog Notes/Classes/thirdparty/CHDataStructures/include/CHQueue.h:
--------------------------------------------------------------------------------
1 | /*
2 | CHDataStructures.framework -- CHQueue.h
3 |
4 | Copyright (c) 2008-2010, Quinn Taylor
5 | Copyright (c) 2002, Phillip Morelock
6 |
7 | This source code is released under the ISC License.
8 |
9 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
10 |
11 | The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
12 | */
13 |
14 | #import "Util.h"
15 |
16 | /**
17 | @file CHQueue.h
18 |
19 | A queue protocol with methods for FIFO ("First In, First Out") operations.
20 | */
21 |
22 | /**
23 | A queue protocol with methods for FIFO ("First In, First Out") operations.
24 |
25 | A queue is commonly compared to waiting in line. When objects are added, they go to the back of the line, and objects are always removed from the front of the line. These actions are accomplished using \link #addObject: -addObject:\endlink and \link #removeFirstObject -removeFirstObject\endlink, respectively. The frontmost object may be examined (not removed) using \link #firstObject -firstObject\endlink.
26 |
27 | @see CHDeque
28 | @see CHStack
29 | */
30 | @protocol CHQueue
31 |
32 | /**
33 | Initialize a queue with no objects.
34 |
35 | @return An initialized queue that contains no objects.
36 |
37 | @see initWithArray:
38 | */
39 | - (id) init;
40 |
41 | /**
42 | Initialize a queue with the contents of an array. Objects are enqueued in the order they occur in the array.
43 |
44 | @param anArray An array containing objects with which to populate a new queue.
45 | @return An initialized queue that contains the objects in @a anArray.
46 | */
47 | - (id) initWithArray:(NSArray*)anArray;
48 |
49 | #pragma mark Querying Contents
50 | /** @name Querying Contents */
51 | // @{
52 |
53 | /**
54 | Returns an array with the objects in this queue, ordered from front to back.
55 |
56 | @return An array with the objects in this queue. If the queue is empty, the array is also empty.
57 |
58 | @see count
59 | @see objectEnumerator
60 | @see removeAllObjects
61 | */
62 | - (NSArray*) allObjects;
63 |
64 | /**
65 | Determine whether the receiver contains a given object, matched using \link NSObject-p#isEqual: -isEqual:\endlink.
66 |
67 | @param anObject The object to test for membership in the receiver.
68 | @return @c YES if the receiver contains @a anObject (as determined by \link NSObject-p#isEqual: -isEqual:\endlink), @c NO if @a anObject is @c nil or not present.
69 |
70 | @see containsObjectIdenticalTo:
71 | @see removeObject:
72 | */
73 | - (BOOL) containsObject:(id)anObject;
74 |
75 | /**
76 | Determine whether the receiver contains a given object, matched using the == operator.
77 |
78 | @param anObject The object to test for membership in the receiver.
79 | @return @c YES if the receiver contains @a anObject (as determined by the == operator), @c NO if @a anObject is @c nil or not present.
80 |
81 | @see containsObject:
82 | @see removeObjectIdenticalTo:
83 | */
84 | - (BOOL) containsObjectIdenticalTo:(id)anObject;
85 |
86 | /**
87 | Returns the number of objects currently in the queue.
88 |
89 | @return The number of objects currently in the queue.
90 |
91 | @see allObjects
92 | */
93 | - (NSUInteger) count;
94 |
95 | /**
96 | Returns the object at the front of the queue without removing it.
97 |
98 | @return The first object in the queue, or @c nil if the queue is empty.
99 |
100 | @see lastObject
101 | @see removeFirstObject
102 | */
103 | - (id) firstObject;
104 |
105 | /**
106 | Returns the lowest index of a given object, matched using @c isEqual:.
107 |
108 | @param anObject The object to search for in the receiver.
109 | @return The index of the first object which is equal to @a anObject. If none of the objects in the receiver match @a anObject, returns @c NSNotFound.
110 |
111 | @see indexOfObjectIdenticalTo:
112 | @see objectAtIndex:
113 | @see removeObjectAtIndex:
114 | */
115 | - (NSUInteger) indexOfObject:(id)anObject;
116 |
117 | /**
118 | Returns the lowest index of a given object, matched using the == operator.
119 |
120 | @param anObject The object to be matched and located in the receiver.
121 | @return The index of the first object which is equal to @a anObject. If none of the objects in the receiver match @a anObject, returns @c NSNotFound.
122 |
123 | @see indexOfObject:
124 | @see objectAtIndex:
125 | @see removeObjectAtIndex:
126 | */
127 | - (NSUInteger) indexOfObjectIdenticalTo:(id)anObject;
128 |
129 | /**
130 | Compares the receiving queue to another queue. Two queues have equal contents if they each hold the same number of objects and objects at a given position in each queue satisfy the \link NSObject-p#isEqual: -isEqual:\endlink test.
131 |
132 | @param otherQueue A queue.
133 | @return @c YES if the contents of @a otherQueue are equal to the contents of the receiver, otherwise @c NO.
134 | */
135 | - (BOOL) isEqualToQueue:(id)otherQueue;
136 |
137 | /**
138 | Returns the object at the back of the queue without removing it.
139 |
140 | @return The last object in the queue, or @c nil if the queue is empty.
141 |
142 | @see addObject:
143 | @see firstObject
144 | */
145 | - (id) lastObject;
146 |
147 | /**
148 | Returns the object located at @a index in the receiver.
149 |
150 | @param index An index from which to retrieve an object.
151 | @return The object located at @a index.
152 |
153 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
154 |
155 | @see indexOfObject:
156 | @see indexOfObjectIdenticalTo:
157 | @see removeObjectAtIndex:
158 | */
159 | - (id) objectAtIndex:(NSUInteger)index;
160 |
161 | /**
162 | Returns an enumerator that accesses each object in the queue from front to back.
163 |
164 | @return An enumerator that accesses each object in the queue from front to back. The enumerator returned is never @c nil; if the queue is empty, the enumerator will always return @c nil for \link NSEnumerator#nextObject -nextObject\endlink and an empty array for \link NSEnumerator#allObjects -allObjects\endlink.
165 |
166 | @attention The enumerator retains the collection. Once all objects in the enumerator have been consumed, the collection is released.
167 | @warning Modifying a collection while it is being enumerated is unsafe, and may cause a mutation exception to be raised.
168 |
169 | @see allObjects
170 | */
171 | - (NSEnumerator*) objectEnumerator;
172 |
173 | /**
174 | Returns an array containing the objects in the receiver at the indexes specified by a given index set.
175 |
176 | @param indexes A set of positions corresponding to objects to retrieve from the receiver.
177 | @return A new array containing the objects in the receiver specified by @a indexes.
178 |
179 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
180 | @throw NSInvalidArgumentException if @a indexes is @c nil.
181 |
182 | @attention To retrieve objects in a given NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
183 |
184 | @see allObjects
185 | @see objectAtIndex:
186 | @see removeObjectsAtIndexes:
187 | */
188 | - (NSArray*) objectsAtIndexes:(NSIndexSet*)indexes;
189 |
190 | // @}
191 | #pragma mark Modifying Contents
192 | /** @name Modifying Contents */
193 | // @{
194 |
195 | /**
196 | Add an object to the back of the queue.
197 |
198 | @param anObject The object to add to the back of the queue.
199 |
200 | @throw NSInvalidArgumentException if @a anObject is @c nil.
201 |
202 | @see lastObject
203 | @see removeFirstObject
204 | */
205 | - (void) addObject:(id)anObject;
206 |
207 | /**
208 | Exchange the objects in the receiver at given indexes.
209 |
210 | @param idx1 The index of the object to replace with the object at @a idx2.
211 | @param idx2 The index of the object to replace with the object at @a idx1.
212 |
213 | @throw NSRangeException if @a idx1 or @a idx2 exceeds the bounds of the receiver.
214 |
215 | @see indexOfObject:
216 | @see objectAtIndex:
217 | */
218 | - (void) exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
219 |
220 | /**
221 | Empty the receiver of all of its members.
222 |
223 | @see allObjects
224 | @see removeFirstObject
225 | @see removeObject:
226 | @see removeObjectIdenticalTo:
227 | */
228 | - (void) removeAllObjects;
229 |
230 | /**
231 | Remove the front object in the queue; no effect if the queue is already empty.
232 |
233 | @see firstObject
234 | @see removeObject:
235 | */
236 | - (void) removeFirstObject;
237 |
238 | /**
239 | Remove @b all occurrences of @a anObject, matched using @c isEqual:.
240 |
241 | @param anObject The object to be removed from the queue.
242 |
243 | If the queue is empty, @a anObject is @c nil, or no object matching @a anObject is found, there is no effect, aside from the possible overhead of searching the contents.
244 |
245 | @see containsObject:
246 | @see removeObjectIdenticalTo:
247 | */
248 | - (void) removeObject:(id)anObject;
249 |
250 | /**
251 | Remove the object at a given index from the receiver.
252 |
253 | @param index The index of the object to remove.
254 |
255 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
256 |
257 | @see indexOfObject:
258 | @see indexOfObjectIdenticalTo:
259 | @see objectAtIndex:
260 | */
261 | - (void) removeObjectAtIndex:(NSUInteger)index;
262 |
263 | /**
264 | Remove @b all occurrences of @a anObject, matched using the == operator.
265 |
266 | @param anObject The object to be removed from the queue.
267 |
268 | If the queue is empty, @a anObject is @c nil, or no object matching @a anObject is found, there is no effect, aside from the possible overhead of searching the contents.
269 |
270 | @see containsObjectIdenticalTo:
271 | @see removeObject:
272 | */
273 | - (void) removeObjectIdenticalTo:(id)anObject;
274 |
275 | /**
276 | Remove the objects at the specified indexes from the receiver. Indexes of elements beyond the first specified index will decrease.
277 | @param indexes A set of positions corresponding to objects to remove from the receiver.
278 |
279 | @throw NSRangeException if any location in @a indexes exceeds the bounds of the receiver.
280 | @throw NSInvalidArgumentException if @a indexes is @c nil.
281 |
282 | @attention To remove objects in a given @c NSRange, pass [NSIndexSet indexSetWithIndexesInRange:range] as the parameter to this method.
283 |
284 | @see objectsAtIndexes:
285 | @see removeAllObjects
286 | @see removeObjectAtIndex:
287 | */
288 | - (void) removeObjectsAtIndexes:(NSIndexSet*)indexes;
289 |
290 | /**
291 | Replaces the object at a given index with a given object.
292 |
293 | @param index The index of the object to be replaced.
294 | @param anObject The object with which to replace the object at @a index in the receiver.
295 |
296 | @throw NSRangeException if @a index exceeds the bounds of the receiver.
297 | @throw NSInvalidArgumentException if @a anObject is @c nil.
298 | */
299 | - (void) replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
300 |
301 | // @}
302 | @end
303 |
--------------------------------------------------------------------------------