Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated to support ARC. EasyTableView now requires ARC.

  • Loading branch information...
commit 5031a91b2479dfe1bf08dfe897246002d1d7d3f5 1 parent 5c8bbbe
Aleksey Novicov authored
View
4 Classes/EasyTableAppDelegate.h
@@ -15,8 +15,8 @@
EasyTableViewController *viewController;
}
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) IBOutlet EasyTableViewController *viewController;
+@property (nonatomic) IBOutlet UIWindow *window;
+@property (nonatomic) IBOutlet EasyTableViewController *viewController;
@end
View
5 Classes/EasyTableAppDelegate.m
@@ -61,11 +61,6 @@ Free up as much memory as possible by purging cached data objects that can be re
}
-- (void)dealloc {
- [viewController release];
- [window release];
- [super dealloc];
-}
@end
View
19 Classes/EasyTableView.h
@@ -60,19 +60,16 @@ typedef enum {
@interface EasyTableView : UIView <UITableViewDelegate, UITableViewDataSource> {
- id<EasyTableViewDelegate> delegate;
- NSIndexPath *_selectedIndexPath;
- UIColor *cellBackgroundColor;
- CGFloat _cellWidthOrHeight;
- NSUInteger _numItems;
- EasyTableViewOrientation _orientation;
+@private
+ CGFloat _cellWidthOrHeight;
+ NSUInteger _numItems;
}
-@property (nonatomic, assign) id<EasyTableViewDelegate> delegate;
-@property (nonatomic, readonly) UITableView *tableView;
-@property (nonatomic, readonly) NSArray *visibleViews;
-@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
-@property (nonatomic, retain) UIColor *cellBackgroundColor;
+@property (nonatomic, weak) id<EasyTableViewDelegate> delegate;
+@property (nonatomic, readonly, weak) UITableView *tableView;
+@property (nonatomic, readonly, weak) NSArray *visibleViews;
+@property (nonatomic) NSIndexPath *selectedIndexPath;
+@property (nonatomic) UIColor *cellBackgroundColor;
@property (nonatomic, readonly) EasyTableViewOrientation orientation;
@property (nonatomic, assign) CGPoint contentOffset;
@property (nonatomic, assign) NSUInteger numberOfCells;
View
15 Classes/EasyTableView.m
@@ -27,11 +27,6 @@ @implementation EasyTableView
#pragma mark -
#pragma mark Initialization
-- (void)dealloc {
- [cellBackgroundColor release];
- [_selectedIndexPath release];
- [super dealloc];
-}
- (id)initWithFrame:(CGRect)frame numberOfColumns:(NSUInteger)numCols ofWidth:(CGFloat)width {
if (self = [super initWithFrame:frame]) {
@@ -81,7 +76,6 @@ - (void)createTableWithOrientation:(EasyTableViewOrientation)orientation {
tableView.showsHorizontalScrollIndicator = NO;
[self addSubview:tableView];
- [tableView release];
}
@@ -150,8 +144,7 @@ - (void)setSelectedIndexPath:(NSIndexPath *)indexPath {
if (![_selectedIndexPath isEqual:indexPath]) {
NSIndexPath *oldIndexPath = [_selectedIndexPath copy];
- [_selectedIndexPath release];
- _selectedIndexPath = [indexPath retain];
+ _selectedIndexPath = indexPath;
UITableViewCell *deselectedCell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:oldIndexPath];
UITableViewCell *selectedCell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:_selectedIndexPath];
@@ -165,7 +158,6 @@ - (void)setSelectedIndexPath:(NSIndexPath *)indexPath {
atIndexPath:_selectedIndexPath
deselectedView:deselectedView];
}
- [oldIndexPath release];
}
}
@@ -319,7 +311,7 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[self setCell:cell boundsForOrientation:_orientation];
@@ -352,7 +344,6 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(
[self prepareRotatedView:rotatedView];
[cell.contentView addSubview:rotatedView];
- [rotatedView release];
}
[self setCell:cell boundsForOrientation:_orientation];
@@ -383,7 +374,7 @@ - (void)prepareRotatedView:(UIView *)rotatedView {
// Add a default view if none is provided
if (content == nil)
- content = [[[UIView alloc] initWithFrame:rotatedView.bounds] autorelease];
+ content = [[UIView alloc] initWithFrame:rotatedView.bounds];
content.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
content.tag = CELL_CONTENT_TAG;
View
6 Classes/EasyTableViewController.h
@@ -16,9 +16,9 @@
EasyTableView *horizontalView;
}
-@property (nonatomic, retain) UILabel *bigLabel;
-@property (nonatomic, retain) EasyTableView *verticalView;
-@property (nonatomic, retain) EasyTableView *horizontalView;
+@property (nonatomic) UILabel *bigLabel;
+@property (nonatomic) EasyTableView *verticalView;
+@property (nonatomic) EasyTableView *horizontalView;
@end
View
13 Classes/EasyTableViewController.m
@@ -36,12 +36,6 @@ @implementation EasyTableViewController
@synthesize bigLabel, verticalView, horizontalView;
-- (void)dealloc {
- [bigLabel release];
- [horizontalView release];
- [verticalView release];
- [super dealloc];
-}
- (void)viewDidLoad {
@@ -82,7 +76,6 @@ - (void)setupHorizontalView {
horizontalView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:horizontalView];
- [view release];
}
@@ -102,7 +95,6 @@ - (void)setupVerticalView {
verticalView.tableView.contentInset = UIEdgeInsetsMake(0, 0, HORIZONTAL_TABLEVIEW_HEIGHT, 0);
[self.view addSubview:verticalView];
- [view release];
}
@@ -123,7 +115,7 @@ - (void)borderIsSelected:(BOOL)selected forView:(UIView *)view {
- (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rect {
CGRect labelRect = CGRectMake(10, 10, rect.size.width-20, rect.size.height-20);
- UILabel *label = [[[UILabel alloc] initWithFrame:labelRect] autorelease];
+ UILabel *label = [[UILabel alloc] initWithFrame:labelRect];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.font = [UIFont boldSystemFontOfSize:60];
@@ -139,7 +131,6 @@ - (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rec
borderView.tag = BORDER_VIEW_TAG;
[label addSubview:borderView];
- [borderView release];
return label;
}
@@ -243,7 +234,7 @@ - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
}
- (IBAction)showInfo:(id)sender {
- FlipsideViewController *controller = [[[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil] autorelease];
+ FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
View
8 Classes/FlipsideViewController.h
@@ -19,10 +19,10 @@
@interface FlipsideViewController : UIViewController <EasyTableViewDelegate, ImageStoreDelegate>
-@property (assign, nonatomic) IBOutlet id<FlipsideViewControllerDelegate> delegate;
-@property (retain, nonatomic) IBOutlet UILabel *errorLabel;
-@property (retain, nonatomic) ImageStore *imageStore;
-@property (retain, nonatomic) EasyTableView *easyTableView;
+@property (nonatomic, weak) IBOutlet id<FlipsideViewControllerDelegate> delegate;
+@property (nonatomic) IBOutlet UILabel *errorLabel;
+@property (nonatomic) ImageStore *imageStore;
+@property (nonatomic) EasyTableView *easyTableView;
- (IBAction)done:(id)sender;
View
13 Classes/FlipsideViewController.m
@@ -22,13 +22,6 @@ @implementation FlipsideViewController
@synthesize easyTableView = _easyTableView;
@synthesize errorLabel = _errorLabel;
-- (void)dealloc {
- [_imageStore release];
- [_easyTableView release];
- [_errorLabel release];
-
- [super dealloc];
-}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
@@ -45,7 +38,6 @@ - (void)viewDidLoad {
ImageStore *store = [[ImageStore alloc] initWithDelegate:self];
self.imageStore = store;
- [store release];
}
- (void)viewDidUnload {
@@ -74,14 +66,13 @@ - (void)setupEasyTableViewWithNumCells:(NSUInteger)count {
self.easyTableView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:self.easyTableView];
- [view release];
}
#pragma mark - EasyTableViewDelegate
- (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rect {
// Create a container view for an EasyTableView cell
- UIView *container = [[[UIView alloc] initWithFrame:rect] autorelease];;
+ UIView *container = [[UIView alloc] initWithFrame:rect];;
// Setup an image view to display an image
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(1, 0, rect.size.width-2, rect.size.height)];
@@ -89,7 +80,6 @@ - (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rec
imageView.contentMode = UIViewContentModeScaleAspectFill;
[container addSubview:imageView];
- [imageView release];
// Setup a label to display the image title
CGRect labelRect = CGRectMake(10, rect.size.height-20, rect.size.width-20, 20);
@@ -101,7 +91,6 @@ - (UIView *)easyTableView:(EasyTableView *)easyTableView viewForRect:(CGRect)rec
label.tag = LABEL_TAG;
[container addSubview:label];
- [label release];
return container;
}
View
10 Classes/ImageStore.h
@@ -18,11 +18,11 @@
@interface ImageStore : NSObject
-@property (assign, nonatomic) id<ImageStoreDelegate> delegate;
-@property (retain, nonatomic) NSOperationQueue *operationQueue;
-@property (retain, nonatomic) NSArray *titles;
-@property (retain, nonatomic) NSArray *urls;
-@property (retain, nonatomic) NSMutableDictionary *imageCache;
+@property (nonatomic, weak) id<ImageStoreDelegate> delegate;
+@property (nonatomic) NSOperationQueue *operationQueue;
+@property (nonatomic) NSArray *titles;
+@property (nonatomic) NSArray *urls;
+@property (nonatomic) NSMutableDictionary *imageCache;
- (id)initWithDelegate:(id<ImageStoreDelegate>)delegate;
- (UIImage *)imageAtIndex:(NSUInteger)index;
View
10 Classes/ImageStore.m
@@ -16,14 +16,6 @@ @implementation ImageStore
@synthesize urls = _urls;
@synthesize imageCache = _imageCache;
-- (void)dealloc {
- [_operationQueue release];
- [_titles release];
- [_urls release];
- [_imageCache release];
-
- [super dealloc];
-}
- (id)initWithDelegate:(id<ImageStoreDelegate>)aDelegate {
self = [super init];
@@ -74,7 +66,6 @@ - (id)initWithDelegate:(id<ImageStoreDelegate>)aDelegate {
// Setup image cache
NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithCapacity:[self.titles count]];
self.imageCache = cache;
- [cache release];
// Make sure to call delegate on main queue
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
@@ -86,7 +77,6 @@ - (id)initWithDelegate:(id<ImageStoreDelegate>)aDelegate {
}];
self.operationQueue = queue;
- [queue release];
}
return self;
}
View
4 EasyTableView.xcodeproj/project.pbxproj
@@ -244,11 +244,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = EasyTableView_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "EasyTableView-Info.plist";
PRODUCT_NAME = EasyTableView;
SDKROOT = iphoneos;
@@ -259,9 +261,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = EasyTableView_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "EasyTableView-Info.plist";
PRODUCT_NAME = EasyTableView;
SDKROOT = iphoneos;
View
3  README
@@ -23,6 +23,9 @@ So now you can create simple partial screen table views, either vertically or ho
CHANGES
+MARCH 5, 2012
+Updated to support ARC. EasyTableView now requires ARC.
+
MARCH 1, 2012
Whereas before EasyTableView was implemented to work with only one table view section, it has now been generalized to work with multiple table view sections. It also now supports section headers and footers. If you would like too see the demo run using just a single table view section, comment out the following line in EasyTableViewController.m:
View
8 main.m
@@ -10,8 +10,8 @@
int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
+ @autoreleasepool {
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ return retVal;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.