Permalink
Browse files

initial import

  • Loading branch information...
1 parent 79d2dad commit 11782e844cccb250c6b3813f275bb985e1424722 @echoz committed Sep 7, 2011
View
@@ -0,0 +1,2 @@
+*.m diff=objc
+*.mm diff=objc
View
@@ -0,0 +1,17 @@
+.DS_Store
+build/*
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+!project.xcworkspace
+xcuserdata
+profile
+*.moved-aside
+.com.apple.timemachine.supported
View
@@ -0,0 +1,34 @@
+//
+// JOGridView.h
+// gridview
+//
+// Created by Jeremy Foo on 9/7/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class JOGridView;
+
+@protocol JOGridViewDelegate <NSObject, UIScrollViewDelegate>
+-(void)willDisplayView:(UIView *)view forGridView:(JOGridView *)gridView atIndexPath:(NSIndexPath *)indexPath;
+@end
+
+@protocol JOGridViewDataSource <NSObject>
+@required
+-(NSUInteger)rowsForGridView:(JOGridView *)gridView;
+-(NSUInteger)columnsForGridView:(JOGridView *)gridView atIndexPath:(NSIndexPath *)indexPath;
+-(UIView *)viewForGridView:(JOGridView *)gridView atIndexPath:(NSIndexPath *)indexPath;
+@end
+
+@interface JOGridView : UIScrollView <UIScrollViewDelegate> {
+ NSMutableDictionary *__reusableViews;
+
+ id <JOGridViewDelegate> externalDelegate;
+ id <JOGridViewDataSource> datasource;
+}
+@property (nonatomic, assign) id<JOGridViewDataSource> datasource;
+
+-(UIView *)dequeueReusableViewWithIdenitifer:(NSString *)identifier;
+
+@end
View
@@ -0,0 +1,84 @@
+//
+// JOGridView.m
+// gridview
+//
+// Created by Jeremy Foo on 9/7/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "JOGridView.h"
+
+@implementation JOGridView
+@synthesize datasource;
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ __reusableViews = [[NSMutableDictionary alloc] initWithCapacity:0];
+ [super setDelegate:self];
+ }
+
+ return self;
+}
+
+-(void)dealloc {
+ [__reusableViews release], __reusableViews = nil;
+ [super dealloc];
+}
+
+#pragma mark -
+#pragma mark Override Accessors
+
+-(void)setDelegate:(id<JOGridViewDelegate, UIScrollViewDelegate>)delegate {
+ if (delegate != (id<JOGridViewDelegate, UIScrollViewDelegate>)self) {
+ externalDelegate = delegate;
+ }
+
+ [super setDelegate:self];
+}
+
+-(id<JOGridViewDelegate, UIScrollViewDelegate>)delegate {
+ return externalDelegate;
+}
+
+#pragma mark -
+#pragma mark View
+
+-(void)layoutSubviews {
+ // layout subviews
+}
+
+-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
+ if (scrollView == self) {
+
+ }
+}
+
+#pragma mark -
+#pragma mark Reusable Views
+
+-(UIView *)dequeueReusableViewWithIdenitifer:(NSString *)identifier {
+
+ NSMutableArray *stack = [__reusableViews objectForKey:identifier];
+
+ if ((stack) && ([stack count] > 0)) {
+
+ UIView *view = [stack objectAtIndex:0];
+ [stack removeObjectAtIndex:0];
+
+ return view;
+ } else {
+ return nil;
+ }
+}
+
+-(void)enqueueReusableView:(UIView *)view withIdentifier:(NSString *)identifier {
+ if ([__reusableViews objectForKey:identifier]) {
+ [[__reusableViews objectForKey:identifier] addObject:view];
+ } else {
+ NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
+ [array addObject:view];
+ [__reusableViews setObject:array forKey:identifier];
+ }
+}
+
+@end
@@ -14,20 +14,23 @@
3FBB3E601417055F00588168 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FBB3E5F1417055F00588168 /* main.m */; };
3FBB3E641417055F00588168 /* gridviewAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FBB3E631417055F00588168 /* gridviewAppDelegate.m */; };
3FBB3E671417055F00588168 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3FBB3E651417055F00588168 /* MainWindow.xib */; };
+ 3FBB3E6F1417058700588168 /* JOGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FBB3E6E1417058700588168 /* JOGridView.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3FBB3E4F1417055F00588168 /* gridview.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = gridview.app; sourceTree = BUILT_PRODUCTS_DIR; };
3FBB3E531417055F00588168 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
3FBB3E551417055F00588168 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3FBB3E571417055F00588168 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 3FBB3E5B1417055F00588168 /* gridview-Info.plist */ = {isa = PBXFileReference; path = "gridview-Info.plist"; sourceTree = "<group>"; };
+ 3FBB3E5B1417055F00588168 /* gridview-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "gridview-Info.plist"; sourceTree = "<group>"; };
3FBB3E5D1417055F00588168 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3FBB3E5F1417055F00588168 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- 3FBB3E611417055F00588168 /* gridview-Prefix.pch */ = {isa = PBXFileReference; path = "gridview-Prefix.pch"; sourceTree = "<group>"; };
- 3FBB3E621417055F00588168 /* gridviewAppDelegate.h */ = {isa = PBXFileReference; path = gridviewAppDelegate.h; sourceTree = "<group>"; };
+ 3FBB3E611417055F00588168 /* gridview-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "gridview-Prefix.pch"; sourceTree = "<group>"; };
+ 3FBB3E621417055F00588168 /* gridviewAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gridviewAppDelegate.h; sourceTree = "<group>"; };
3FBB3E631417055F00588168 /* gridviewAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = gridviewAppDelegate.m; sourceTree = "<group>"; };
3FBB3E661417055F00588168 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = "<group>"; };
+ 3FBB3E6D1417058700588168 /* JOGridView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JOGridView.h; sourceTree = "<group>"; };
+ 3FBB3E6E1417058700588168 /* JOGridView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JOGridView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -47,6 +50,8 @@
3FBB3E441417055F00588168 = {
isa = PBXGroup;
children = (
+ 3FBB3E6D1417058700588168 /* JOGridView.h */,
+ 3FBB3E6E1417058700588168 /* JOGridView.m */,
3FBB3E591417055F00588168 /* gridview */,
3FBB3E521417055F00588168 /* Frameworks */,
3FBB3E501417055F00588168 /* Products */,
@@ -154,6 +159,7 @@
files = (
3FBB3E601417055F00588168 /* main.m in Sources */,
3FBB3E641417055F00588168 /* gridviewAppDelegate.m in Sources */,
+ 3FBB3E6F1417058700588168 /* JOGridView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 11782e8

Please sign in to comment.