Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

arc migration assistant (targeting iOS 4 ie. no __weak) with a little…

… help
  • Loading branch information...
commit c0953f14970b7b421d14a10793a5f756b8f5e4c1 1 parent 41acc77
Mark Aufflick aufflick authored
2  AQGridView.xcodeproj/project.pbxproj
View
@@ -281,6 +281,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/AQGridView.dst;
GCC_DYNAMIC_NO_PIC = NO;
@@ -302,6 +303,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/AQGridView.dst;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
2  Classes/AQGridView.h
View
@@ -97,7 +97,7 @@ extern NSString * const AQGridViewSelectionDidChangeNotification;
@interface AQGridView : UIScrollView
{
- id<AQGridViewDataSource> _dataSource;
+ id<AQGridViewDataSource> __unsafe_unretained _dataSource;
AQGridViewData * _gridData;
NSMutableArray * _updateInfoStack;
113 Classes/AQGridView.m
View
@@ -152,21 +152,6 @@ - (void)drawRect:(CGRect)rect {
}
*/
-- (void)dealloc
-{
- [_visibleCells release];
- [_reusableGridCells release];
- [_highlightedIndices release];
- [_backgroundView release];
- [_separatorColor release];
- [_gridData release];
- [_updateInfoStack release];
- [_animatingCells release];
- [_headerView release];
- [_footerView release];
-
- [super dealloc];
-}
#pragma mark -
#pragma mark Properties
@@ -361,7 +346,7 @@ - (CGSize) gridCellSize
- (UIView *) gridHeaderView
{
- return ( [[_headerView retain] autorelease] );
+ return ( _headerView );
}
- (void) setGridHeaderView: (UIView *) newHeaderView
@@ -370,9 +355,8 @@ - (void) setGridHeaderView: (UIView *) newHeaderView
return;
[_headerView removeFromSuperview];
- [_headerView release];
- _headerView = [newHeaderView retain];
+ _headerView = newHeaderView;
if ( _headerView == nil )
{
_gridData.topPadding = 0.0;
@@ -388,7 +372,7 @@ - (void) setGridHeaderView: (UIView *) newHeaderView
- (UIView *) gridFooterView
{
- return ( [[_footerView retain] autorelease] );
+ return ( _footerView );
}
- (void) setGridFooterView: (UIView *) newFooterView
@@ -397,9 +381,8 @@ - (void) setGridFooterView: (UIView *) newFooterView
return;
[_footerView removeFromSuperview];
- [_footerView release];
- _footerView = [newFooterView retain];
+ _footerView = newFooterView;
if ( _footerView == nil )
{
_gridData.bottomPadding = 0.0;
@@ -425,8 +408,6 @@ - (void) setContentSizeGrowsToFillBounds: (BOOL) value
- (void) setAnimatingCells: (NSSet *) set
{
- [set retain];
- [_animatingCells release];
_animatingCells = set;
NSMutableIndexSet * indices = [[NSMutableIndexSet alloc] init];
@@ -437,7 +418,6 @@ - (void) setAnimatingCells: (NSSet *) set
}
self.animatingIndices = indices;
- [indices release];
}
- (BOOL) isAnimatingUpdates
@@ -596,14 +576,14 @@ - (void) setEditing: (BOOL) value
- (AQGridViewCell *) dequeueReusableCellWithIdentifier: (NSString *) reuseIdentifier
{
NSMutableSet * cells = [_reusableGridCells objectForKey: reuseIdentifier];
- AQGridViewCell * cell = [[cells anyObject] retain];
+ AQGridViewCell * cell = [cells anyObject];
if ( cell == nil )
return ( nil );
[cell prepareForReuse];
[cells removeObject: cell];
- return ( [cell autorelease] );
+ return ( cell );
}
- (void) enqueueReusableCells: (NSArray *) reusableCells
@@ -615,7 +595,6 @@ - (void) enqueueReusableCells: (NSArray *) reusableCells
{
reuseSet = [[NSMutableSet alloc] initWithCapacity: 32];
[_reusableGridCells setObject: reuseSet forKey: cell.reuseIdentifier];
- [reuseSet release];
}
else if ( [reuseSet member: cell] == cell )
{
@@ -677,9 +656,9 @@ - (void) layoutSubviews
if ( (_reloadingSuspendedCount == 0) && (!CGRectIsEmpty([self gridViewVisibleBounds])) )
{
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- [self updateVisibleGridCellsNow];
- [pool release];
+ @autoreleasepool {
+ [self updateVisibleGridCellsNow];
+ }
}
if ( _flags.allCellsNeedLayout == 1 )
@@ -787,7 +766,7 @@ - (AQGridViewCell *) cellForItemAtPoint: (CGPoint) point
- (NSArray *) visibleCells
{
- return ( [[_visibleCells copy] autorelease] );
+ return ( [_visibleCells copy] );
}
- (NSIndexSet *) visibleCellIndices
@@ -901,7 +880,6 @@ - (void) fixCellsFromAnimation
[_visibleCells removeObjectsInArray: newVisibleCells];
[_visibleCells makeObjectsPerformSelector: @selector(removeFromSuperview)];
[_visibleCells setArray: newVisibleCells];
- [newVisibleCells release];
self.animatingCells = nil;
NSMutableSet * removals = [[NSMutableSet alloc] init];
@@ -915,7 +893,6 @@ - (void) fixCellsFromAnimation
}
[removals makeObjectsPerformSelector: @selector(removeFromSuperview)];
- [removals release];
// update the content size/offset based on the new grid data
CGPoint oldMaxLocation = CGPointMake(CGRectGetMaxX(self.bounds), CGRectGetMaxY(self.bounds));
@@ -928,7 +905,6 @@ - (void) setupUpdateAnimations
AQGridViewUpdateInfo * info = [[AQGridViewUpdateInfo alloc] initWithOldGridData: _gridData forGridView: self];
[_updateInfoStack addObject: info];
- [info release];
}
- (void) endUpdateAnimations
@@ -960,13 +936,12 @@ - (void) endUpdateAnimations
// there's a race condition with the info's removal from the stack if there are no animations taking place,
// where -cellUpdateAnimationStopped:finished:context: is called immediately, before we've finished with the
// object. Therefore we retain it while we want to use it, just in case
- [info retain];
[info cleanupUpdateItems];
_animationCount++;
//NSAssert(_animationCount == 1, @"Stacked animations occurring!!");
- [UIView beginAnimations: @"CellUpdates" context: info];
+ [UIView beginAnimations: @"CellUpdates" context: (void*)objc_unretainedPointer(info)];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: @selector(cellUpdateAnimationStopped:finished:context:)];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
@@ -975,12 +950,10 @@ - (void) endUpdateAnimations
self.animatingCells = [info animateCellUpdatesUsingVisibleContentRect: [self gridViewVisibleBounds]];
- [_gridData release];
- _gridData = [[info newGridViewData] retain];
+ _gridData = [info newGridViewData];
if ( _selectedIndex != NSNotFound )
_selectedIndex = [info newIndexForOldIndex: _selectedIndex];
- [info release];
_reloadingSuspendedCount--;
[UIView commitAnimations];
}
@@ -1202,7 +1175,7 @@ - (void) deselectItemAtIndex: (NSUInteger) index animated: (BOOL) animated
- (UIView *) backgroundView
{
- return ( [[_backgroundView retain] autorelease] );
+ return ( _backgroundView );
}
- (void) setBackgroundView: (UIView *) newView
@@ -1211,9 +1184,8 @@ - (void) setBackgroundView: (UIView *) newView
return;
[_backgroundView removeFromSuperview];
- [_backgroundView release];
- _backgroundView = [newView retain];
+ _backgroundView = newView;
_backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
CGRect frame = self.bounds;
frame.size = self.contentSize;
@@ -1238,7 +1210,7 @@ - (void) setBackgroundView: (UIView *) newView
- (UIColor *) separatorColor
{
- return ( [[_separatorColor retain] autorelease] );
+ return ( _separatorColor );
}
- (void) setSeparatorColor: (UIColor *) color
@@ -1246,8 +1218,6 @@ - (void) setSeparatorColor: (UIColor *) color
if ( color == _separatorColor )
return;
- [color retain];
- [_separatorColor release];
_separatorColor = color;
for ( AQGridViewCell * cell in _visibleCells )
@@ -1289,7 +1259,7 @@ - (BOOL) _canSelectItemContainingHitView: (UIView *) hitView
CGPoint hitCenter = [self convertPoint:[hitView center] fromView:hitView];
- for ( AQGridViewCell *aCell in [[[self visibleCells] copy] autorelease])
+ for ( AQGridViewCell *aCell in [[self visibleCells] copy])
{
if ( CGRectContainsPoint( aCell.frame, hitCenter ) )
@@ -1367,7 +1337,7 @@ - (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
CGPoint pt = [touch locationInView: self];
UIView * hitView = [self _basicHitTest: pt withEvent: event];
- _touchedContentView = [hitView retain];
+ _touchedContentView = hitView;
// unhighlight anything not here
if ( hitView != self )
@@ -1418,7 +1388,6 @@ - (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event
//[self _cancelContentTouchUsingEvent: event forced: NO];
[self highlightItemAtIndex: NSNotFound animated: NO scrollPosition: AQGridViewScrollPositionNone];
_flags.ignoreTouchSelect = 1;
- [_touchedContentView release];
_touchedContentView = nil;
}
@@ -1438,13 +1407,11 @@ - (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
[super touchesEnded: touches withEvent: event];
if ( _touchedContentView != nil )
{
- [hitView release];
- hitView = [_touchedContentView retain];
+ hitView = _touchedContentView;
}
if ( [hitView superview] == nil )
{
- [hitView release];
hitView = nil;
}
@@ -1471,14 +1438,13 @@ - (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
NSSet *touchEventSet = [event allTouches];
// run this on the next runloop tick
- UserSelectItemIndexParams* selectorParams = [[[UserSelectItemIndexParams alloc] init] autorelease];
+ UserSelectItemIndexParams* selectorParams = [[UserSelectItemIndexParams alloc] init];
selectorParams.indexNum = _pendingSelectionIndex;
selectorParams.numFingers = [touchEventSet count];
[self performSelector: @selector(_userSelectItemAtIndex:)
withObject: selectorParams
afterDelay:0.0];
- [hitView release];
} while (0);
@@ -1493,7 +1459,6 @@ - (void) touchesCancelled: (NSSet *) touches withEvent: (UIEvent *) event
[self highlightItemAtIndex: NSNotFound animated: NO scrollPosition: AQGridViewScrollPositionNone];
[super touchesCancelled: touches withEvent: event];
- [_touchedContentView release];
_touchedContentView = nil;
}
@@ -1583,13 +1548,13 @@ - (void) updateVisibleGridCellsNow
// TODO: if we replace _visibleIndices with an index set, this comparison will have to change
if ( [currentVisibleIndices intersectsIndexesInRange: _visibleIndices] == NO )
{
- removedIndices = [[currentVisibleIndices mutableCopy] autorelease];
- insertedIndices = [[newVisibleIndices mutableCopy] autorelease];
+ removedIndices = [currentVisibleIndices mutableCopy];
+ insertedIndices = [newVisibleIndices mutableCopy];
}
else // more complicated -- compute negative intersections
{
- removedIndices = [[[currentVisibleIndices aq_indexesOutsideIndexSet: newVisibleIndices] mutableCopy] autorelease];
- insertedIndices = [[[newVisibleIndices aq_indexesOutsideIndexSet: currentVisibleIndices] mutableCopy] autorelease];
+ removedIndices = [[currentVisibleIndices aq_indexesOutsideIndexSet: newVisibleIndices] mutableCopy];
+ insertedIndices = [[newVisibleIndices aq_indexesOutsideIndexSet: currentVisibleIndices] mutableCopy];
}
if ( [removedIndices count] != 0 )
@@ -1617,7 +1582,7 @@ - (void) updateVisibleGridCellsNow
//NSLog( @"After removals, visible cells count = %lu", (unsigned long)[_visibleCells count] );
// don't need this any more
- [shifted release]; shifted = nil;
+ shifted = nil;
// remove cells from the view hierarchy -- but only if they're not being animated by something else
NSArray * animating = [[self.animatingCells valueForKey: @"animatingView"] allObjects];
@@ -1630,7 +1595,6 @@ - (void) updateVisibleGridCellsNow
// put them into the cell reuse queue
[self enqueueReusableCells: removedCells];
- [removedCells release];
}
if ( [insertedIndices count] != 0 )
@@ -1680,7 +1644,6 @@ - (void) updateVisibleGridCellsNow
[insertedIndices removeIndexes: animatingInserted];
}
- [animatingInserted release];
// insert cells for these indices
idx = [insertedIndices firstIndex];
@@ -1731,8 +1694,6 @@ - (void) updateVisibleGridCellsNow
// all removed from superview, just need to remove from the list now
[_visibleCells removeObjectsAtIndexes: toRemove];
- [toRemove release];
- [seen release];
}
if ( [_visibleCells count] < [newVisibleIndices count] )
@@ -1747,7 +1708,6 @@ - (void) updateVisibleGridCellsNow
NSMutableIndexSet * missingSet = [newVisibleIndices mutableCopy];
[missingSet removeIndexes: visibleSet];
- [visibleSet release];
NSLog( @"Got %lu missing indices", (unsigned long)[missingSet count] );
@@ -1764,7 +1724,6 @@ - (void) updateVisibleGridCellsNow
idx = [missingSet indexGreaterThanIndex: idx];
}
- [missingSet release];
}
// everything should match up now, so update the visible range
@@ -2105,22 +2064,22 @@ - (void) layoutCellsInVisibleCellRange: (NSRange) range
{
NSParameterAssert(range.location + range.length <= [_visibleCells count]);
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ @autoreleasepool {
- NSArray * layoutList = [_visibleCells subarrayWithRange: range];
- for ( AQGridViewCell * cell in layoutList )
- {
- if ( [_animatingIndices containsIndex: cell.displayIndex] )
- continue; // don't adjust layout of something that is animating around
+ NSArray * layoutList = [_visibleCells subarrayWithRange: range];
+ for ( AQGridViewCell * cell in layoutList )
+ {
+ if ( [_animatingIndices containsIndex: cell.displayIndex] )
+ continue; // don't adjust layout of something that is animating around
- CGRect gridRect = [_gridData cellRectAtIndex: cell.displayIndex];
- CGRect cellFrame = cell.frame;
+ CGRect gridRect = [_gridData cellRectAtIndex: cell.displayIndex];
+ CGRect cellFrame = cell.frame;
- cell.frame = [self fixCellFrame: cellFrame forGridRect: gridRect];
- cell.selected = (cell.displayIndex == _selectedIndex);
- }
+ cell.frame = [self fixCellFrame: cellFrame forGridRect: gridRect];
+ cell.selected = (cell.displayIndex == _selectedIndex);
+ }
- [pool drain];
+ }
}
- (void) layoutAllCells
11 Classes/AQGridViewAnimatorItem.m
View
@@ -17,14 +17,9 @@ + (AQGridViewAnimatorItem *) itemWithView: (UIView *) aView index: (NSUInteger)
AQGridViewAnimatorItem * result = [[self alloc] init];
result.animatingView = aView;
result.index = anIndex;
- return ( [result autorelease] );
+ return ( result );
}
-- (void) dealloc
-{
- self.animatingView = nil;
- [super dealloc];
-}
- (NSUInteger) hash
{
@@ -43,9 +38,9 @@ - (NSComparisonResult) compare: (id) obj
{
if ( [obj isKindOfClass: [self class]] == NO )
{
- if ( (void *)self < (void *)obj )
+ if ( (void *)objc_unretainedPointer(self) < (void *)objc_unretainedPointer(obj) )
return ( NSOrderedAscending );
- if ( (void *)self > (void *)obj )
+ if ( (void *)objc_unretainedPointer(self) > (void *)objc_unretainedPointer(obj) )
return ( NSOrderedDescending );
return ( NSOrderedSame ); // how ??!?!?
}
40 Classes/AQGridViewCell.m
View
@@ -96,20 +96,8 @@ - (void) awakeFromNib
- (void) dealloc
{
- [_reuseIdentifier release];
- [_contentView release];
- [_backgroundView release];
- [_selectedBackgroundView release];
- [_selectedOverlayView release];
- [_backgroundColor release];
- [_separatorColor release];
- [_selectionGlowColor release];
- [_bottomSeparatorView release];
- [_rightSeparatorView release];
if ( _selectionColorInfo != NULL )
CFRelease( _selectionColorInfo );
- [_fadeTimer release];
- [super dealloc];
}
- (NSComparisonResult) compareOriginAgainstCell: (AQGridViewCell *) otherCell
@@ -208,11 +196,11 @@ - (void) makeSubviewsOfView: (UIView *) aView nonOpaqueWithBackgroundColor: (UIC
{
if ( view.opaque )
{
- NSMutableDictionary * info = (NSMutableDictionary *) CFDictionaryGetValue( _selectionColorInfo, view );
+ NSMutableDictionary * info = (NSMutableDictionary *) objc_unretainedObject(CFDictionaryGetValue( _selectionColorInfo, objc_unretainedPointer(view) ));
if ( info == nil )
{
info = [NSMutableDictionary dictionaryWithCapacity: 2];
- CFDictionarySetValue( _selectionColorInfo, view, info );
+ CFDictionarySetValue( _selectionColorInfo, objc_unretainedPointer(view), objc_unretainedPointer(info) );
}
id value = view.backgroundColor;
@@ -232,7 +220,7 @@ - (void) makeSubviewsOfViewOpaqueAgain: (UIView *) aView
{
for ( UIView * view in aView.subviews )
{
- NSMutableDictionary * info = (NSMutableDictionary *) CFDictionaryGetValue( _selectionColorInfo, view );
+ NSMutableDictionary * info = (NSMutableDictionary *) objc_unretainedObject(CFDictionaryGetValue( _selectionColorInfo, objc_unretainedPointer(view) ));
if ( info != nil )
{
id value = [info objectForKey: @"backgroundColor"];
@@ -257,11 +245,11 @@ - (void) highlightSubviewsOfView: (UIView *) aView
{
if ( [view respondsToSelector: @selector(setHighlighted:)] )
{
- NSMutableDictionary * info = (NSMutableDictionary *) CFDictionaryGetValue( _selectionColorInfo, view );
+ NSMutableDictionary * info = (NSMutableDictionary *) objc_unretainedObject(CFDictionaryGetValue( _selectionColorInfo, objc_unretainedPointer(view) ));
if ( info == nil )
{
info = [NSMutableDictionary dictionaryWithCapacity: 2];
- CFDictionarySetValue( _selectionColorInfo, view, info );
+ CFDictionarySetValue( _selectionColorInfo, objc_unretainedPointer(view), objc_unretainedPointer(info) );
}
// don't overwrite any prior cache of a view's original highlighted state.
@@ -287,7 +275,7 @@ - (void) resetHighlightForSubviewsOfView: (UIView *) aView
for ( UIView * view in aView.subviews )
{
if ([view respondsToSelector:@selector(setHighlighted:)]) {
- NSMutableDictionary * info = (NSMutableDictionary *) CFDictionaryGetValue( _selectionColorInfo, view );
+ NSMutableDictionary * info = (NSMutableDictionary *) objc_unretainedObject(CFDictionaryGetValue( _selectionColorInfo, objc_unretainedPointer(view) ));
if ( info != nil )
{
id value = [info objectForKey: @"highlighted"];
@@ -394,7 +382,6 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
if ( _fadeTimer != nil )
{
[_fadeTimer invalidate];
- [_fadeTimer release];
}
_fadeTimer = [[NSTimer alloc] initWithFireDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]
@@ -529,8 +516,7 @@ - (void) setBackgroundView: (UIView *) aView
if ( _backgroundView.superview == self )
[_backgroundView removeFromSuperview];
- [_backgroundView release];
- _backgroundView = [aView retain];
+ _backgroundView = aView;
_backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -572,7 +558,6 @@ - (void) layoutSubviews
else if ( _bottomSeparatorView != nil )
{
[_bottomSeparatorView removeFromSuperview];
- [_bottomSeparatorView release];
_bottomSeparatorView = nil;
}
@@ -592,7 +577,6 @@ - (void) layoutSubviews
else if ( _rightSeparatorView != nil )
{
[_rightSeparatorView removeFromSuperview];
- [_rightSeparatorView release];
_rightSeparatorView = nil;
}
}
@@ -604,8 +588,6 @@ - (void) layoutSubviews
- (void) setSelectionGlowColor: (UIColor *) aColor
{
- [aColor retain];
- [_selectionGlowColor release];
_selectionGlowColor = aColor;
_cellFlags.selectionGlowColorSet = (aColor == nil ? 0 : 1);
@@ -619,8 +601,7 @@ - (void) setSelectedBackgroundView: (UIView *) aView
if ( _selectedBackgroundView.superview == self )
[_selectedBackgroundView removeFromSuperview];
- [_selectedBackgroundView release];
- _selectedBackgroundView = [aView retain];
+ _selectedBackgroundView = aView;
_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -665,7 +646,7 @@ @implementation AQGridViewCell (AQGridViewCellPrivate)
- (UIColor *) separatorColor
{
- return ( [[_separatorColor retain] autorelease] );
+ return ( _separatorColor );
}
- (void) setSeparatorColor: (UIColor *) color
@@ -673,8 +654,7 @@ - (void) setSeparatorColor: (UIColor *) color
if ( _separatorColor == color )
return;
- [_separatorColor release];
- _separatorColor = [color retain];
+ _separatorColor = color;
_bottomSeparatorView.backgroundColor = _separatorColor;
_rightSeparatorView.backgroundColor = _separatorColor;
4 Classes/AQGridViewController.m
View
@@ -57,7 +57,6 @@ - (void) loadView
{
AQGridView * aView = [[AQGridView alloc] initWithFrame: CGRectZero];
self.gridView = aView;
- [aView release];
[self _sharedGridViewDefaultSetup];
}
@@ -152,9 +151,6 @@ - (void)viewDidUnload {
}
-- (void)dealloc {
- [super dealloc];
-}
#pragma mark -
#pragma mark Grid View Data Source
43 Classes/AQGridViewUpdateInfo.m
View
@@ -66,23 +66,10 @@ - (id) initWithOldGridData: (AQGridViewData *) oldGridData forGridView: (AQGridV
- (void) dealloc
{
- [_insertItems release];
- [_deleteItems release];
- [_reloadItems release];
- [_moveItems release];
- [_insertedIndices release];
- [_deletedIndices release];
- [_reloadedIndices release];
- [_oldMovedIndices release];
- [_newMovedIndices release];
- [_oldGridData release];
- [_newGridData release];
if ( _oldToNewIndexMap != NULL )
free( _oldToNewIndexMap );
if ( _newToOldIndexMap != NULL )
free( _newToOldIndexMap );
- [_onlyMovedIndices release];
- [super dealloc];
}
- (NSMutableArray *) updateItemArrayForAction: (AQGridViewUpdateAction) action
@@ -120,7 +107,6 @@ - (void) updateItemsAtIndices: (NSIndexSet *) indices
action: action
animation: animation];
[array addObject: item];
- [item release];
i = [indices indexGreaterThanIndex: i];
}
@@ -136,7 +122,6 @@ - (void) moveItemAtIndex: (NSUInteger) index
animation: animation];
item.newIndex = newIndex;
[array addObject: item];
- [item release];
}
- (NSUInteger) numberOfUpdates
@@ -358,8 +343,6 @@ - (void) updateNewGridDataAndCreateMappingTables
}
}
- [oldToNewIndices release];
- [newToOldIndices release];
}
- (void) cleanupUpdateItems
@@ -450,27 +433,27 @@ - (NSUInteger) newIndexForOldIndex: (NSUInteger) oldIndex
- (NSArray *) sortedInsertItems
{
- return ( [[_insertItems copy] autorelease] );
+ return ( [_insertItems copy] );
}
- (NSArray *) sortedDeleteItems
{
- return ( [[_deleteItems copy] autorelease] );
+ return ( [_deleteItems copy] );
}
- (NSArray *) sortedMoveItems
{
- return ( [[_moveItems copy] autorelease] );
+ return ( [_moveItems copy] );
}
- (NSArray *) sortedReloadItems
{
- return ( [[_reloadItems copy] autorelease] );
+ return ( [_reloadItems copy] );
}
- (AQGridViewData *) newGridViewData
{
- return ( [[_newGridData retain] autorelease] );
+ return ( _newGridData );
}
- (NSUInteger) numberOfItemsAfterUpdates
@@ -487,7 +470,7 @@ - (UIImageView *) _imageViewForView: (UIView *) view
UIGraphicsEndImageContext();
- return ( [result autorelease] );
+ return ( result );
}
- (UIImageView *) animateDeletionForCell: (AQGridViewCell *) cell withAnimation: (AQGridViewItemAnimation) animation
@@ -635,7 +618,6 @@ - (void) animateInsertionForCell: (AQGridViewCell *) cell withAnimation: (AQGrid
{
[cell setValue: [itemsToSetBeforeAnimation objectForKey: keyPath] forKey: keyPath];
}
- [itemsToSetBeforeAnimation release];
[UIView setAnimationsEnabled: YES];
for ( NSString * keyPath in itemsToAnimate )
@@ -643,7 +625,6 @@ - (void) animateInsertionForCell: (AQGridViewCell *) cell withAnimation: (AQGrid
[cell setValue: [itemsToAnimate objectForKey: keyPath] forKey: keyPath];
}
- [itemsToAnimate release];
}
- (void) animateReloadForCell: (AQGridViewCell *) newCell originalCell: (AQGridViewCell *) originalCell withAnimation: (AQGridViewItemAnimation) animation
@@ -773,7 +754,7 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
{
// only store real cells here
if ( [item.animatingView isKindOfClass: [AQGridViewCell class]] )
- CFDictionaryAddValue( animatingCellTable, (void *)item.index, item );
+ CFDictionaryAddValue( animatingCellTable, (void *)item.index, objc_unretainedPointer(item) );
}
// a set of the indices (in old grid data) for all currently-known cells which are now or will become visible
@@ -787,13 +768,12 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
NSMutableIndexSet * movingSet = [[NSMutableIndexSet alloc] initWithIndexSet: oldVisibleIndices];
[movingSet addIndexes: oldIndicesOfAllVisibleCells];
- [oldIndicesOfAllVisibleCells release];
// most items were just moved from one location to another
for ( NSUInteger oldIndex = [movingSet firstIndex]; oldIndex != NSNotFound; oldIndex = [movingSet indexGreaterThanIndex: oldIndex] )
{
NSUInteger newIndex = _oldToNewIndexMap[oldIndex];
- AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)CFDictionaryGetValue( animatingCellTable, (void *)oldIndex );
+ AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)objc_unretainedObject(CFDictionaryGetValue( animatingCellTable, (void *)oldIndex ));
AQGridViewCell * cell = (AQGridViewCell *)animatingItem.animatingView;
if ( cell == nil )
@@ -843,7 +823,6 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
[_gridView delegateWillDisplayCell: cell atIndex: newIndex];
}
- [movingSet release];
// delete old items first
if ( _deleteItems.count != 0 )
@@ -853,7 +832,7 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
{
if ( [oldVisibleIndices containsIndex: item.originalIndex] )
{
- AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)CFDictionaryGetValue( animatingCellTable, (void *)item.originalIndex );
+ AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)objc_unretainedObject(CFDictionaryGetValue( animatingCellTable, (void *)item.originalIndex ));
AQGridViewCell * deletingCell = (AQGridViewCell *)animatingItem.animatingView;
if ( deletingCell == nil )
@@ -898,7 +877,7 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
if ( [newVisibleIndices containsIndex: item.index] == NO )
continue;
- AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)CFDictionaryGetValue( animatingCellTable, (void *)item.originalIndex );
+ AQGridViewAnimatorItem * animatingItem = (AQGridViewAnimatorItem *)objc_unretainedObject(CFDictionaryGetValue( animatingCellTable, (void *)item.originalIndex ));
AQGridViewCell * origCell = (AQGridViewCell *)animatingItem.animatingView;
if ( origCell == nil )
@@ -930,7 +909,7 @@ - (NSSet *) animateCellUpdatesUsingVisibleContentRect: (CGRect) contentRect
CFRelease( animatingCellTable );
- return ( [newVisibleCells autorelease] );
+ return ( newVisibleCells );
}
@end
3  Classes/NSIndexSet+AQIndexesOutsideSet.m
View
@@ -16,8 +16,7 @@ - (NSIndexSet *) aq_indexesOutsideIndexSet: (NSIndexSet *) otherSet
NSMutableIndexSet * mutable = [self mutableCopy];
[mutable removeIndexes: otherSet];
NSIndexSet * result = [mutable copy];
- [mutable release];
- return ( [result autorelease] );
+ return ( result );
}
@end
5 Examples/ImageDemo/Classes/ImageDemoAppDelegate.m
View
@@ -55,11 +55,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
-- (void)dealloc {
- [viewController release];
- [window release];
- [super dealloc];
-}
@end
4 Examples/ImageDemo/Classes/ImageDemoCellChooser.h
View
@@ -43,12 +43,12 @@
@interface ImageDemoCellChooser : UITableViewController
{
NSArray * _itemTitles;
- id<ImageDemoCellChooserDelegate> __weak _delegate;
+ id<ImageDemoCellChooserDelegate> __unsafe_unretained _delegate;
}
- (id) initWithItemTitles: (NSArray *) titles;
-@property (nonatomic, assign) id<ImageDemoCellChooserDelegate> __weak delegate;
+@property (nonatomic, assign) id<ImageDemoCellChooserDelegate> delegate;
@end
7 Examples/ImageDemo/Classes/ImageDemoCellChooser.m
View
@@ -57,11 +57,6 @@ - (id) initWithItemTitles: (NSArray *) titles
return ( self );
}
-- (void) dealloc
-{
- [_itemTitles release];
- [super dealloc];
-}
#pragma mark -
#pragma mark View lifecycle
@@ -129,7 +124,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [_itemTitles objectAtIndex: indexPath.row];
6 Examples/ImageDemo/Classes/ImageDemoFilledCell.m
View
@@ -64,12 +64,6 @@ - (id) initWithFrame: (CGRect) frame reuseIdentifier: (NSString *) aReuseIdentif
return ( self );
}
-- (void) dealloc
-{
- [_imageView release];
- [_title release];
- [super dealloc];
-}
- (UIImage *) image
{
5 Examples/ImageDemo/Classes/ImageDemoGridViewCell.m
View
@@ -52,11 +52,6 @@ - (id) initWithFrame: (CGRect) frame reuseIdentifier: (NSString *) aReuseIdentif
return ( self );
}
-- (void) dealloc
-{
- [_imageView release];
- [super dealloc];
-}
- (CALayer *) glowSelectionLayer
{
24 Examples/ImageDemo/Classes/ImageDemoViewController.m
View
@@ -64,7 +64,6 @@ - (void) viewDidLoad
ImageDemoCellChooser * chooser = [[ImageDemoCellChooser alloc] initWithItemTitles: [NSArray arrayWithObjects: NSLocalizedString(@"Plain", @""), NSLocalizedString(@"Filled", @""), nil]];
chooser.delegate = self;
_menuPopoverController = [[UIPopoverController alloc] initWithContentViewController: chooser];
- [chooser release];
if ( _orderedImageNames != nil )
return;
@@ -84,7 +83,6 @@ - (void) viewDidLoad
_orderedImageNames = [[allImageNames sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] copy];
_imageNames = [_orderedImageNames copy];
- [allImageNames release];
[self.gridView reloadData];
}
@@ -100,17 +98,9 @@ - (void) viewDidUnload
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.gridView = nil;
- [_menuPopoverController release]; _menuPopoverController = nil;
+ _menuPopoverController = nil;
}
-- (void) dealloc
-{
- [_gridView release];
- [_imageNames release];
- [_orderedImageNames release];
- [_menuPopoverController release];
- [super dealloc];
-}
- (IBAction) shuffle
{
@@ -135,13 +125,10 @@ - (IBAction) shuffle
[sourceArray removeObjectAtIndex: index];
}
- [_imageNames release];
_imageNames = [destArray copy];
[self.gridView endUpdates];
- [sourceArray release];
- [destArray release];
}
- (IBAction) resetOrder
@@ -160,7 +147,6 @@ - (IBAction) resetOrder
[self.gridView endUpdates];
- [_imageNames release];
_imageNames = [_orderedImageNames copy];
}
@@ -249,8 +235,8 @@ - (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSU
ImageDemoGridViewCell * plainCell = (ImageDemoGridViewCell *)[aGridView dequeueReusableCellWithIdentifier: PlainCellIdentifier];
if ( plainCell == nil )
{
- plainCell = [[[ImageDemoGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
- reuseIdentifier: PlainCellIdentifier] autorelease];
+ plainCell = [[ImageDemoGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
+ reuseIdentifier: PlainCellIdentifier];
plainCell.selectionGlowColor = [UIColor blueColor];
}
@@ -265,8 +251,8 @@ - (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSU
ImageDemoFilledCell * filledCell = (ImageDemoFilledCell *)[aGridView dequeueReusableCellWithIdentifier: FilledCellIdentifier];
if ( filledCell == nil )
{
- filledCell = [[[ImageDemoFilledCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
- reuseIdentifier: FilledCellIdentifier] autorelease];
+ filledCell = [[ImageDemoFilledCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
+ reuseIdentifier: FilledCellIdentifier];
filledCell.selectionStyle = AQGridViewCellSelectionStyleBlueGray;
}
4 Examples/ImageDemo/ImageDemo.xcodeproj/project.pbxproj
View
@@ -410,11 +410,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 = ImageDemo_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "ImageDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = ImageDemo;
@@ -425,9 +427,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 = ImageDemo_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "ImageDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = ImageDemo;
7 Examples/ImageDemo/main.m
View
@@ -10,8 +10,9 @@
int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
+ int retVal;
+ @autoreleasepool {
+ retVal = UIApplicationMain(argc, argv, nil, nil);
+ }
return retVal;
}
5 Examples/SpringBoard/Classes/SpringBoardAppDelegate.m
View
@@ -55,11 +55,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
-- (void)dealloc {
- [viewController release];
- [window release];
- [super dealloc];
-}
@end
5 Examples/SpringBoard/Classes/SpringBoardIconCell.m
View
@@ -71,11 +71,6 @@ - (id) initWithFrame: (CGRect) frame reuseIdentifier:(NSString *) reuseIdentifie
return ( self );
}
-- (void) dealloc
-{
- [_iconView release];
- [super dealloc];
-}
- (UIImage *) icon
{
20 Examples/SpringBoard/Classes/SpringBoardViewController.m
View
@@ -82,7 +82,6 @@ - (void) viewDidLoad
gr.minimumPressDuration = 0.5;
gr.delegate = self;
[_gridView addGestureRecognizer: gr];
- [gr release];
if ( _icons == nil )
{
@@ -207,10 +206,9 @@ - (void) moveActionGestureRecognizerStateChanged: (UIGestureRecognizer *) recogn
}
// update the data store
- id obj = [[_icons objectAtIndex: _dragOriginIndex] retain];
+ id obj = [_icons objectAtIndex: _dragOriginIndex];
[_icons removeObjectAtIndex: _dragOriginIndex];
[_icons insertObject: obj atIndex: index];
- [obj release];
if ( index != _emptyCellIndex )
{
@@ -342,10 +340,8 @@ - (void) finishedSnap: (NSString *) animationID finished: (NSNumber *) finished
// dismiss our copy of the cell
[_draggingCell removeFromSuperview];
- [_draggingCell release];
_draggingCell = nil;
- [indices release];
}
#pragma mark -
@@ -369,8 +365,8 @@ - (AQGridViewCell *) gridView: (AQGridView *) gridView cellForItemAtIndex: (NSUI
{
// must be the SAME SIZE AS THE OTHERS
// Yes, this is probably a bug. Sigh. Look at -[AQGridView fixCellsFromAnimation] to fix
- hiddenCell = [[[AQGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 72.0, 72.0)
- reuseIdentifier: EmptyIdentifier] autorelease];
+ hiddenCell = [[AQGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 72.0, 72.0)
+ reuseIdentifier: EmptyIdentifier];
}
hiddenCell.hidden = YES;
@@ -380,7 +376,7 @@ - (AQGridViewCell *) gridView: (AQGridView *) gridView cellForItemAtIndex: (NSUI
SpringBoardIconCell * cell = (SpringBoardIconCell *)[gridView dequeueReusableCellWithIdentifier: CellIdentifier];
if ( cell == nil )
{
- cell = [[[SpringBoardIconCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 72.0, 72.0) reuseIdentifier: CellIdentifier] autorelease];
+ cell = [[SpringBoardIconCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 72.0, 72.0) reuseIdentifier: CellIdentifier];
}
cell.icon = [_icons objectAtIndex: index];
@@ -397,14 +393,8 @@ - (void) viewDidUnload
{
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
- [_gridView release]; _gridView = nil;
+ _gridView = nil;
}
-- (void) dealloc
-{
- [_icons release];
- [_gridView release];
- [super dealloc];
-}
@end
4 Examples/SpringBoard/SpringBoard.xcodeproj/project.pbxproj
View
@@ -265,11 +265,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 = SpringBoard_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "SpringBoard-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = SpringBoard;
@@ -280,9 +282,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 = SpringBoard_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "SpringBoard-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = SpringBoard;
7 Examples/SpringBoard/main.m
View
@@ -10,8 +10,9 @@
int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
+ int retVal;
+ @autoreleasepool {
+ retVal = UIApplicationMain(argc, argv, nil, nil);
+ }
return retVal;
}
Please sign in to comment.
Something went wrong with that request. Please try again.