From e404217e8b0382f546b84d8592d5c9387e7dcc03 Mon Sep 17 00:00:00 2001 From: Derek Hammer Date: Sun, 22 May 2011 17:55:17 -0500 Subject: [PATCH 1/2] Elaborate what setItemPrototype expects and does in CPCollectionView. --- AppKit/CPCollectionView.j | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index a48c11c39..7b39d2b41 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -131,6 +131,49 @@ /*! Sets the item prototype to \c anItem + + The item prototype should implement the CPCoding protocol + because the item is copied by archiving and unarchiving the + prototypal view. + + Example: + +
+      @implement MyCustomView : CPCollectionViewItem
+      {
+          CPArray   items   @accessors;
+      }
+
+      - (id)initWithFrame:(CGRect)aFrame
+      {
+        self = [super initWithFrame:aFrame];
+        if (self)
+        {
+          items = [];
+        }
+        return self;
+      }
+
+      - (id)initWithCoder:(CPCoder)aCoder
+      {
+        self = [super initWithCoder:aCoder];
+        items = [aCoder decodeObjectForKey:@"KEY"];
+        return self;
+      }
+
+      - (void)encodeWithCoder:(CPCoder)aCoder
+      {
+        [aCoder encodeObject:items forKey:@"KEY"];
+        [super encodeWithCoder:aCoder];
+      }
+
+      @end
+    
+
+    This will allow the collection view to create multiple 'clean' copies
+    of the item prototype which will maintain the original values for item
+    and all of the properties archived by the super class.
+
     @param anItem the new item prototype
 */
 - (void)setItemPrototype:(CPCollectionViewItem)anItem

From 7194a6961ada1e6d4e34db66a33105b8a6449164 Mon Sep 17 00:00:00 2001
From: Derek Hammer 
Date: Sun, 22 May 2011 17:58:25 -0500
Subject: [PATCH 2/2] Forgot a forward slash to end the pre tag.

---
 AppKit/CPCollectionView.j | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j
index 7b39d2b41..99d3db162 100644
--- a/AppKit/CPCollectionView.j
+++ b/AppKit/CPCollectionView.j
@@ -168,7 +168,7 @@
       }
 
       @end
-    
+    
This will allow the collection view to create multiple 'clean' copies of the item prototype which will maintain the original values for item