summaryrefslogtreecommitdiff
path: root/CyteKit
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-02-28 21:21:58 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-07 02:41:31 -0800
commit5276ff21e3ed70bb2c65099fff053e7eac49a936 (patch)
treecf376b7212197be2f3bcae125fbc4f3ae7f69a74 /CyteKit
parentf172aa8f89e1ab4ae00f63ea961e04a8125ba419 (diff)
Move WebScriptObject (NSFastEnumeration) to (Cyte).
Diffstat (limited to 'CyteKit')
-rw-r--r--CyteKit/WebScriptObject-Cyte.h1
-rw-r--r--CyteKit/WebScriptObject-Cyte.mm13
2 files changed, 14 insertions, 0 deletions
diff --git a/CyteKit/WebScriptObject-Cyte.h b/CyteKit/WebScriptObject-Cyte.h
index 6da0d8c..d071ea6 100644
--- a/CyteKit/WebScriptObject-Cyte.h
+++ b/CyteKit/WebScriptObject-Cyte.h
@@ -44,6 +44,7 @@
@interface WebScriptObject (Cyte)
- (NSUInteger) count;
+- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)objects count:(NSUInteger)count;
- (id) objectAtIndex:(unsigned)index;
@end
diff --git a/CyteKit/WebScriptObject-Cyte.mm b/CyteKit/WebScriptObject-Cyte.mm
index 9df6f85..36b02dd 100644
--- a/CyteKit/WebScriptObject-Cyte.mm
+++ b/CyteKit/WebScriptObject-Cyte.mm
@@ -53,4 +53,17 @@
return [self webScriptValueAtIndex:index];
}
+- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)objects count:(NSUInteger)count {
+ size_t length([self count] - state->state);
+ if (length <= 0)
+ return 0;
+ else if (length > count)
+ length = count;
+ for (size_t i(0); i != length; ++i)
+ objects[i] = [self objectAtIndex:state->state++];
+ state->itemsPtr = objects;
+ state->mutationsPtr = (unsigned long *) self;
+ return length;
+}
+
@end