Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Making it ARC compatible

Making it ARC compatible
  • Loading branch information...
commit f9eb71db5facb90540e79a78a326be7b1dbec150 1 parent 4f8f57c
@hmimthiaz authored
View
2  Classes/Popover/UIBarButtonItem+WEPopover.m
@@ -18,7 +18,6 @@ - (CGRect)frameInView:(UIView *)v {
if (!hasCustomView) {
UIView *tempView = [[UIView alloc] initWithFrame:CGRectZero];
self.customView = tempView;
- [tempView release];
}
UIView *parentView = self.customView.superview;
@@ -38,7 +37,6 @@ - (UIView *)superview {
if (!hasCustomView) {
UIView *tempView = [[UIView alloc] initWithFrame:CGRectZero];
self.customView = tempView;
- [tempView release];
}
UIView *parentView = self.customView.superview;
View
12 Classes/Popover/WEPopoverContainerView.h
@@ -27,11 +27,11 @@
CGFloat arrowMargin;
}
-@property(nonatomic, retain) NSString *bgImageName;
-@property(nonatomic, retain) NSString *upArrowImageName;
-@property(nonatomic, retain) NSString *downArrowImageName;
-@property(nonatomic, retain) NSString *leftArrowImageName;
-@property(nonatomic, retain) NSString *rightArrowImageName;
+@property(nonatomic) NSString *bgImageName;
+@property(nonatomic) NSString *upArrowImageName;
+@property(nonatomic) NSString *downArrowImageName;
+@property(nonatomic) NSString *leftArrowImageName;
+@property(nonatomic) NSString *rightArrowImageName;
@property(nonatomic, assign) CGFloat leftBgMargin;
@property(nonatomic, assign) CGFloat rightBgMargin;
@property(nonatomic, assign) CGFloat topBgMargin;
@@ -76,7 +76,7 @@
/**
* @brief The content view being displayed.
*/
-@property (nonatomic, retain) UIView *contentView;
+@property (nonatomic) UIView *contentView;
/**
* @brief Initializes the position of the popover with a size, anchor rect, display area and permitted arrow directions and optionally the properties.
View
31 Classes/Popover/WEPopoverContainerView.m
@@ -13,14 +13,6 @@ @implementation WEPopoverContainerViewProperties
@synthesize bgImageName, upArrowImageName, downArrowImageName, leftArrowImageName, rightArrowImageName, topBgMargin, bottomBgMargin, leftBgMargin, rightBgMargin, topBgCapSize, leftBgCapSize;
@synthesize leftContentMargin, rightContentMargin, topContentMargin, bottomContentMargin, arrowMargin;
-- (void)dealloc {
- self.bgImageName = nil;
- self.upArrowImageName = nil;
- self.downArrowImageName = nil;
- self.leftArrowImageName = nil;
- self.rightArrowImageName = nil;
- [super dealloc];
-}
@end
@@ -52,7 +44,7 @@ - (id)initWithSize:(CGSize)theSize
[self initFrame];
self.backgroundColor = [UIColor clearColor];
UIImage *theImage = [UIImage imageNamed:properties.bgImageName];
- bgImage = [[theImage stretchableImageWithLeftCapWidth:properties.leftBgCapSize topCapHeight:properties.topBgCapSize] retain];
+ bgImage = [theImage stretchableImageWithLeftCapWidth:properties.leftBgCapSize topCapHeight:properties.topBgCapSize];
self.clipsToBounds = YES;
self.userInteractionEnabled = YES;
@@ -60,13 +52,6 @@ - (id)initWithSize:(CGSize)theSize
return self;
}
-- (void)dealloc {
- [properties release];
- [contentView release];
- [bgImage release];
- [arrowImage release];
- [super dealloc];
-}
- (void)drawRect:(CGRect)rect {
[bgImage drawInRect:bgRect blendMode:kCGBlendModeNormal alpha:1.0];
@@ -102,8 +87,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
- (void)setContentView:(UIView *)v {
if (v != contentView) {
- [contentView release];
- contentView = [v retain];
+ contentView = v;
contentView.frame = self.contentRect;
[self addSubview:contentView];
}
@@ -140,8 +124,7 @@ - (CGRect)contentRect {
- (void)setProperties:(WEPopoverContainerViewProperties *)props {
if (properties != props) {
- [properties release];
- properties = [props retain];
+ properties = props;
}
}
@@ -345,16 +328,16 @@ - (void)determineGeometryForSize:(CGSize)theSize anchorRect:(CGRect)anchorRect d
switch (arrowDirection) {
case UIPopoverArrowDirectionUp:
- arrowImage = [upArrowImage retain];
+ arrowImage = upArrowImage;
break;
case UIPopoverArrowDirectionDown:
- arrowImage = [downArrowImage retain];
+ arrowImage = downArrowImage;
break;
case UIPopoverArrowDirectionLeft:
- arrowImage = [leftArrowImage retain];
+ arrowImage = leftArrowImage;
break;
case UIPopoverArrowDirectionRight:
- arrowImage = [rightArrowImage retain];
+ arrowImage = rightArrowImage;
break;
}
}
View
14 Classes/Popover/WEPopoverController.h
@@ -25,27 +25,27 @@
*/
@interface WEPopoverController : NSObject<WETouchableViewDelegate> {
UIViewController *contentViewController;
- UIView *view;
+ UIView *__weak view;
WETouchableView *backgroundView;
BOOL popoverVisible;
UIPopoverArrowDirection popoverArrowDirection;
- id <WEPopoverControllerDelegate> delegate;
+ id <WEPopoverControllerDelegate> __unsafe_unretained delegate;
CGSize popoverContentSize;
WEPopoverContainerViewProperties *containerViewProperties;
id <NSObject> context;
NSArray *passthroughViews;
}
-@property(nonatomic, retain) UIViewController *contentViewController;
+@property(nonatomic) UIViewController *contentViewController;
-@property (nonatomic, readonly) UIView *view;
+@property (weak, nonatomic, readonly) UIView *view;
@property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;
@property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;
-@property (nonatomic, assign) id <WEPopoverControllerDelegate> delegate;
+@property (nonatomic, unsafe_unretained) id <WEPopoverControllerDelegate> delegate;
@property (nonatomic, assign) CGSize popoverContentSize;
-@property (nonatomic, retain) WEPopoverContainerViewProperties *containerViewProperties;
-@property (nonatomic, retain) id <NSObject> context;
+@property (nonatomic) WEPopoverContainerViewProperties *containerViewProperties;
+@property (nonatomic) id <NSObject> context;
@property (nonatomic, copy) NSArray *passthroughViews;
- (id)initWithContentViewController:(UIViewController *)theContentViewController;
View
22 Classes/Popover/WEPopoverController.m
@@ -51,24 +51,17 @@ - (id)initWithContentViewController:(UIViewController *)viewController {
- (void)dealloc {
[self dismissPopoverAnimated:NO];
- [contentViewController release];
- [containerViewProperties release];
- [passthroughViews release];
- self.context = nil;
- [super dealloc];
}
- (void)setContentViewController:(UIViewController *)vc {
if (vc != contentViewController) {
- [contentViewController release];
- contentViewController = [vc retain];
+ contentViewController = vc;
popoverContentSize = CGSizeZero;
}
}
//Overridden setter to copy the passthroughViews to the background view if it exists already
- (void)setPassthroughViews:(NSArray *)array {
- [passthroughViews release];
passthroughViews = nil;
if (array) {
passthroughViews = [[NSArray alloc] initWithArray:array];
@@ -88,10 +81,9 @@ - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished c
[self.view removeFromSuperview];
self.view = nil;
[backgroundView removeFromSuperview];
- [backgroundView release];
backgroundView = nil;
- BOOL userInitiatedDismissal = [(NSNumber *)theContext boolValue];
+ BOOL userInitiatedDismissal = [(__bridge NSNumber *)theContext boolValue];
if (userInitiatedDismissal && [delegate respondsToSelector: @selector(popoverControllerDidDismissPopover:)]) {
//Only send message to delegate in case the user initiated this event, which is if he touched outside the view
@@ -133,7 +125,7 @@ - (void)presentPopoverFromRect:(CGRect)rect
CGRect displayArea = [self displayAreaForView:theView];
WEPopoverContainerViewProperties *props = self.containerViewProperties ? self.containerViewProperties : [self defaultContainerViewProperties];
- WEPopoverContainerView *containerView = [[[WEPopoverContainerView alloc] initWithSize:self.popoverContentSize anchorRect:rect displayArea:displayArea permittedArrowDirections:arrowDirections properties:props] autorelease];
+ WEPopoverContainerView *containerView = [[WEPopoverContainerView alloc] initWithSize:self.popoverContentSize anchorRect:rect displayArea:displayArea permittedArrowDirections:arrowDirections properties:props];
popoverArrowDirection = containerView.arrowDirection;
UIView *keyView = self.keyView;
@@ -225,8 +217,7 @@ - (UIView *)keyView {
- (void)setView:(UIView *)v {
if (view != v) {
- [view release];
- view = [v retain];
+ view = v;
}
}
@@ -243,7 +234,7 @@ - (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated
if (animated) {
self.view.userInteractionEnabled = NO;
- [UIView beginAnimations:@"FadeOut" context:[NSNumber numberWithBool:userInitiated]];
+ [UIView beginAnimations:@"FadeOut" context:(__bridge void *)([NSNumber numberWithBool:userInitiated])];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
@@ -257,7 +248,6 @@ - (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated
[self.view removeFromSuperview];
self.view = nil;
[backgroundView removeFromSuperview];
- [backgroundView release];
backgroundView = nil;
}
}
@@ -275,7 +265,7 @@ - (CGRect)displayAreaForView:(UIView *)theView {
//Enable to use the simple popover style
- (WEPopoverContainerViewProperties *)defaultContainerViewProperties {
- WEPopoverContainerViewProperties *ret = [[WEPopoverContainerViewProperties new] autorelease];
+ WEPopoverContainerViewProperties *ret = [WEPopoverContainerViewProperties new];
CGSize imageSize = CGSizeMake(30.0f, 30.0f);
NSString *bgImageName = @"popoverBgSimple.png";
View
4 Classes/Popover/WETouchableView.h
@@ -24,13 +24,13 @@
*/
@interface WETouchableView : UIView {
BOOL touchForwardingDisabled;
- id <WETouchableViewDelegate> delegate;
+ id <WETouchableViewDelegate> __unsafe_unretained delegate;
NSArray *passthroughViews;
BOOL testHits;
}
@property (nonatomic, assign) BOOL touchForwardingDisabled;
-@property (nonatomic, assign) id <WETouchableViewDelegate> delegate;
+@property (nonatomic, unsafe_unretained) id <WETouchableViewDelegate> delegate;
@property (nonatomic, copy) NSArray *passthroughViews;
@end
View
4 Classes/Popover/WETouchableView.m
@@ -18,10 +18,6 @@ @implementation WETouchableView
@synthesize touchForwardingDisabled, delegate, passthroughViews;
-- (void)dealloc {
- [passthroughViews release];
- [super dealloc];
-}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (testHits) {
View
4 Classes/WEPopoverAppDelegate.h
@@ -15,8 +15,8 @@
UINavigationController *navController;
}
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) IBOutlet UINavigationController *navController;
+@property (nonatomic) IBOutlet UIWindow *window;
+@property (nonatomic) IBOutlet UINavigationController *navController;
@end
View
5 Classes/WEPopoverAppDelegate.m
@@ -78,11 +78,6 @@ Free up as much memory as possible by purging cached data objects that can be re
}
-- (void)dealloc {
- [navController release];
- [window release];
- [super dealloc];
-}
@end
View
5 Classes/WEPopoverContentViewController.m
@@ -86,7 +86,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];
}
// Configure the cell...
@@ -121,9 +121,6 @@ - (void)viewDidUnload {
}
-- (void)dealloc {
- [super dealloc];
-}
@end
View
2  Classes/WEPopoverTableViewController.h
@@ -15,7 +15,7 @@
Class popoverClass;
}
-@property (nonatomic, retain) WEPopoverController *popoverController;
+@property (nonatomic) WEPopoverController *popoverController;
- (IBAction)showPopover:(id)sender;
View
13 Classes/WEPopoverTableViewController.m
@@ -103,7 +103,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 = [NSString stringWithFormat:@"Cell %d", indexPath.row];
@@ -156,7 +156,7 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
*/
- (WEPopoverContainerViewProperties *)improvedContainerViewProperties {
- WEPopoverContainerViewProperties *props = [[WEPopoverContainerViewProperties alloc] autorelease];
+ WEPopoverContainerViewProperties *props = [WEPopoverContainerViewProperties alloc];
NSString *bgImageName = nil;
CGFloat bgMargin = 0.0;
CGFloat bgCapSize = 0.0;
@@ -210,7 +210,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
//CGRect rect = CGRectMake(frame.size.width * percentage, frame.origin.y, 1, frame.size.height);
CGRect rect = frame;
- self.popoverController = [[[popoverClass alloc] initWithContentViewController:contentViewController] autorelease];
+ self.popoverController = [[popoverClass alloc] initWithContentViewController:contentViewController];
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
@@ -230,7 +230,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
animated:YES];
currentPopoverCellIndex = indexPath.row;
- [contentViewController release];
}
}
@@ -243,7 +242,7 @@ - (IBAction)showPopover:(id)sender {
if (!self.popoverController) {
UIViewController *contentViewController = [[WEPopoverContentViewController alloc] initWithStyle:UITableViewStylePlain];
- self.popoverController = [[[popoverClass alloc] initWithContentViewController:contentViewController] autorelease];
+ self.popoverController = [[popoverClass alloc] initWithContentViewController:contentViewController];
self.popoverController.delegate = self;
self.popoverController.passthroughViews = [NSArray arrayWithObject:self.navigationController.navigationBar];
@@ -251,7 +250,6 @@ - (IBAction)showPopover:(id)sender {
permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown)
animated:YES];
- [contentViewController release];
} else {
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController = nil;
@@ -282,9 +280,6 @@ - (void)didReceiveMemoryWarning {
// Relinquish ownership any cached data, images, etc. that aren't in use.
}
-- (void)dealloc {
- [super dealloc];
-}
@end
View
2  Classes/WEPopoverViewController.h
@@ -14,7 +14,7 @@
WEPopoverController *popoverController;
}
-@property (nonatomic, retain) WEPopoverController *popoverController;
+@property (nonatomic) WEPopoverController *popoverController;
- (IBAction)onButtonClick:(UIButton *)button;
View
4 Classes/WEPopoverViewController.m
@@ -70,19 +70,17 @@ - (IBAction)onButtonClick:(UIButton *)button {
} else {
UIViewController *contentViewController = [[WEPopoverContentViewController alloc] initWithStyle:UITableViewStylePlain];
- self.popoverController = [[[WEPopoverController alloc] initWithContentViewController:contentViewController] autorelease];
+ self.popoverController = [[WEPopoverController alloc] initWithContentViewController:contentViewController];
[self.popoverController presentPopoverFromRect:button.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown
animated:YES];
- [contentViewController release];
[button setTitle:@"Hide Popover" forState:UIControlStateNormal];
}
}
- (void)dealloc {
[self viewDidUnload];
- [super dealloc];
}
@end
View
4 WEPopover.xcodeproj/project.pbxproj
@@ -314,11 +314,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 = WEPopover_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "WEPopover-Info.plist";
PRODUCT_NAME = WEPopover;
};
@@ -328,9 +330,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 = WEPopover_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "WEPopover-Info.plist";
PRODUCT_NAME = WEPopover;
VALIDATE_PRODUCT = YES;
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.