Permalink
Browse files

[refactor] We are riding ARC from now on

  • Loading branch information...
1 parent beedbe6 commit 44574941a565b7d0a50c7228d9126194a9a3da75 @johanfirebase johanfirebase committed Dec 30, 2012
@@ -11,29 +11,22 @@
@protocol FireUIPagedScrollViewDelegate;
-@interface FireUIPagedScrollView : UIScrollView<UIScrollViewDelegate> {
- NSMutableArray * _controllers;
- NSInteger _currentPage;
- BOOL _dontInferPagesFromScrollRange;
- UIPageControl * _pageControl;
- UISegmentedControl * _segmentedControl;
- BOOL _ignoreValueChangedEvent;
-}
+@interface FireUIPagedScrollView : UIScrollView<UIScrollViewDelegate>
// Set the delegate to get notified when the current page is changed.
-@property (nonatomic, retain) IBOutlet id<FireUIPagedScrollViewDelegate> pagerDelegate;
+@property (nonatomic, strong) IBOutlet id<FireUIPagedScrollViewDelegate> pagerDelegate;
// The current page index. (Zero based).
-@property (nonatomic, readwrite) NSInteger currentPage;
+@property (nonatomic) NSInteger currentPage;
// The number of Pages.
@property (nonatomic, readonly) NSInteger pageCount;
// Set a UIPageControl to handle selection of Pages and provide visual feedback.
-@property (nonatomic, retain, readwrite) IBOutlet UIPageControl * pageControl;
+@property (nonatomic, strong) IBOutlet UIPageControl * pageControl;
// Set a UISegmentedControl to handle selection of Pages and provide visual feedback.
-@property (nonatomic, retain, readwrite) IBOutlet UISegmentedControl * segmentedControl;
+@property (nonatomic, strong) IBOutlet UISegmentedControl * segmentedControl;
// Adds a Controller.
-(void)addPagedViewController:(UIViewController*)controller;
@@ -48,6 +41,7 @@
-(void)willRotateToInterfaceOrientation;
-(IBAction)paginationControlChanged:(id)sender;
+
@end
@protocol FireUIPagedScrollViewDelegate<NSObject>
@@ -10,6 +10,7 @@
#import "FireUIPagedScrollView.h"
@interface FireUIPagedScrollView(hidden)
+
-(void)_niceInit;
-(void)_adjustSizesForPages;
-(void)_adjustSizesForPages:(BOOL)animated;
@@ -19,7 +20,15 @@ -(void)_adjustSizesForPagesCoreInit;
-(void)_adjustSizesForPagesCoreCompletion;
@end
-@implementation FireUIPagedScrollView
+@implementation FireUIPagedScrollView {
+ NSMutableArray * _controllers;
+ NSInteger _currentPage;
+ BOOL _dontInferPagesFromScrollRange;
+ UIPageControl * _pageControl;
+ UISegmentedControl * _segmentedControl;
+ BOOL _ignoreValueChangedEvent;
+}
+
@synthesize pagerDelegate;
- (id)init
@@ -63,12 +72,10 @@ -(void)_niceInit {
}
-(void)dealloc {
- [_controllers release];
self.pagerDelegate = nil;
self.delegate = nil;
self.segmentedControl = nil;
self.pageControl = nil;
- [super dealloc];
}
@@ -218,8 +225,7 @@ -(void)setPageControl:(UIPageControl *)pageControl {
if(_pageControl != nil) {
[_pageControl removeTarget:self action:@selector(paginationControlChanged:) forControlEvents:UIControlEventValueChanged];
}
- [_pageControl release];
- _pageControl = [pageControl retain];
+ _pageControl = pageControl;
if(_pageControl != nil) {
[_pageControl addTarget:self action:@selector(paginationControlChanged:) forControlEvents:UIControlEventValueChanged];
}
@@ -231,8 +237,7 @@ -(void)setSegmentedControl:(UISegmentedControl *)segmentedControl {
if(_segmentedControl != nil) {
[_segmentedControl removeTarget:self action:@selector(paginationControlChanged:) forControlEvents:UIControlEventValueChanged];
}
- [_segmentedControl release];
- _segmentedControl = [segmentedControl retain];
+ _segmentedControl = segmentedControl;
if(_segmentedControl != nil) {
[_segmentedControl addTarget:self action:@selector(paginationControlChanged:) forControlEvents:UIControlEventValueChanged];
}
View
@@ -8,6 +8,7 @@ Very nice UIScrollView ready to handle View Controllers as pages, handle orienta
* Handles Orientation and Size changes automatically and with smooth animations.
* Ready to work with [UIPageControl](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPageControl_Class/Reference/Reference.html) and [UISegmentedControl](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UISegmentedControl_Class/Reference/UISegmentedControl.html)
* Easy to use properties and methods (addPagedViewController, pageCount, currentPage, etc)
+* LLVM-ARC Enabled
## Screenshots
@@ -42,11 +43,11 @@ Let's setup you have three View controllers that you want to show as pages as fo
{
[super viewDidLoad];
// Add Page 1
- [self.pagedScrollView addPagedViewController:[[[Page1ViewController alloc] initWithNibName:@"Page1View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[Page1ViewController alloc] initWithNibName:@"Page1View" bundle:nil];
// Add Page 2
- [self.pagedScrollView addPagedViewController:[[[Page2ViewController alloc] initWithNibName:@"Page2View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[Page2ViewController alloc] initWithNibName:@"Page2View" bundle:nil];
// Add Page 3
- [self.pagedScrollView addPagedViewController:[[[Page3ViewController alloc] initWithNibName:@"Page3View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[Page3ViewController alloc] initWithNibName:@"Page3View" bundle:nil];
}
## Handling Orientation Changes
@@ -66,10 +67,14 @@ Get the source code and run the samples for iPhone or iPad:
git clone git://github.com/firebaseco/FireUIPagedScrollView.git
+## ARC Compatibility
+
+Starting with 1.1, you will need to use Apple's LLVM Compiler and iOS 4.3 minimum.
+
+For projects pre iOS 4.3 still using GCC you can use the version [1.0](https://github.com/firebaseco/FireUIPagedScrollView/tree/v1.0) as a reference for your own implementation.
## Author
Johan Hernandez: johan@firebase.co
-Drop me an email if you need anything, thanks!
## License
@@ -91,4 +96,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE.
@@ -287,14 +287,15 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -309,10 +310,11 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -20,16 +20,16 @@ @implementation FireUIPagedScrollViewiPadSampleAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- RootViewController* firstVC = [[[RootViewController alloc]
- initWithNibName:@"RootViewController" bundle:nil] autorelease];
- WelcomeDetailsController* welcome = [[[WelcomeDetailsController alloc]
- initWithNibName:@"WelcomeDetailsController" bundle:nil] autorelease];
+ RootViewController* firstVC = [[RootViewController alloc]
+ initWithNibName:@"RootViewController" bundle:nil];
+ WelcomeDetailsController* welcome = [[WelcomeDetailsController alloc]
+ initWithNibName:@"WelcomeDetailsController" bundle:nil];
- UINavigationController* secondVC = [[[UINavigationController alloc] initWithRootViewController:welcome] autorelease];
+ UINavigationController* secondVC = [[UINavigationController alloc] initWithRootViewController:welcome];
firstVC.detailViewController = secondVC;
- self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
+ self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil];
@@ -79,13 +79,4 @@ - (void)applicationWillTerminate:(UIApplication *)application
*/
}
-- (void)dealloc
-{
- [_window release];
- [_splitViewController release];
- [_rootViewController release];
- [_detailViewController release];
- [super dealloc];
-}
-
@end
@@ -50,7 +50,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];
}
switch (indexPath.row) {
@@ -74,12 +74,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[self.detailViewController popViewControllerAnimated:NO];
switch (indexPath.row) {
case kSimplePages: {
- SimpleSampleView * sampleView = [[[SimpleSampleView alloc] initWithNibName:@"SimpleSampleView" bundle:nil] autorelease];
+ SimpleSampleView * sampleView = [[SimpleSampleView alloc] initWithNibName:@"SimpleSampleView" bundle:nil];
[self.detailViewController pushViewController:sampleView animated:YES];
break;
}
case kVisualsReadyPages: {
- VisualsReadySampleView * sampleView = [[[VisualsReadySampleView alloc] initWithNibName:@"VisualsReadySampleView" bundle:nil] autorelease];
+ VisualsReadySampleView * sampleView = [[VisualsReadySampleView alloc] initWithNibName:@"VisualsReadySampleView" bundle:nil];
[self.detailViewController pushViewController:sampleView animated:YES];
break;
}
@@ -89,10 +89,4 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
-- (void)dealloc
-{
- [detailViewController release];
- [super dealloc];
-}
-
@end
@@ -17,9 +17,9 @@ @implementation SimpleSampleView
- (void)viewDidLoad
{
[super viewDidLoad];
- [self.pagedScrollView addPagedViewController:[[[Page1View alloc] initWithNibName:@"Page1View" bundle:nil] autorelease]];
- [self.pagedScrollView addPagedViewController:[[[Page2View alloc] initWithNibName:@"Page2View" bundle:nil] autorelease]];
- [self.pagedScrollView addPagedViewController:[[[Page3View alloc] initWithNibName:@"Page3View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[Page1View alloc] initWithNibName:@"Page1View" bundle:nil]];
+ [self.pagedScrollView addPagedViewController:[[Page2View alloc] initWithNibName:@"Page2View" bundle:nil] ];
+ [self.pagedScrollView addPagedViewController:[[Page3View alloc] initWithNibName:@"Page3View" bundle:nil]];
}
- (void)viewDidUnload
@@ -21,9 +21,9 @@ - (void)viewDidLoad
Nothing to see here hehe, everything was made in Interface Builder :) If you want to use UIPageControl or UISegmentedControl you can use Interface Builder to assign the outlets properties pageControl and segmentedControl.
*/
- [self.pagedScrollView addPagedViewController:[[[Page1View alloc] initWithNibName:@"Page1View" bundle:nil] autorelease]];
- [self.pagedScrollView addPagedViewController:[[[Page2View alloc] initWithNibName:@"Page2View" bundle:nil] autorelease]];
- [self.pagedScrollView addPagedViewController:[[[Page3View alloc] initWithNibName:@"Page3View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[Page1View alloc] initWithNibName:@"Page1View" bundle:nil]];
+ [self.pagedScrollView addPagedViewController:[[Page2View alloc] initWithNibName:@"Page2View" bundle:nil]];
+ [self.pagedScrollView addPagedViewController:[[Page3View alloc] initWithNibName:@"Page3View" bundle:nil]];
}
- (void)viewDidUnload
@@ -10,8 +10,6 @@
int main(int argc, char *argv[])
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
return retVal;
}
@@ -321,7 +321,7 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -338,7 +338,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -352,6 +352,7 @@
07B852781404BFFB00047EFD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "FireUIPagedScrollViewiPhoneSample/FireUIPagedScrollViewiPhoneSample-Prefix.pch";
INFOPLIST_FILE = "FireUIPagedScrollViewiPhoneSample/FireUIPagedScrollViewiPhoneSample-Info.plist";
@@ -363,6 +364,7 @@
07B852791404BFFB00047EFD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "FireUIPagedScrollViewiPhoneSample/FireUIPagedScrollViewiPhoneSample-Prefix.pch";
INFOPLIST_FILE = "FireUIPagedScrollViewiPhoneSample/FireUIPagedScrollViewiPhoneSample-Info.plist";
@@ -390,6 +392,7 @@
07B852791404BFFB00047EFD /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -62,11 +62,4 @@ - (void)applicationWillTerminate:(UIApplication *)application
*/
}
-- (void)dealloc
-{
- [_window release];
- [_navigationController release];
- [super dealloc];
-}
-
@end
@@ -38,13 +38,13 @@ - (void)viewDidLoad
self.title = @"Orientation Demo";
// Add Page 1
- [self.pagedScrollView addPagedViewController:[[[SimplePage1View alloc] initWithNibName:@"SimplePage1View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[SimplePage1View alloc] initWithNibName:@"SimplePage1View" bundle:nil]];
// Add Page 2
- [self.pagedScrollView addPagedViewController:[[[SimplePage2View alloc] initWithNibName:@"SimplePage2View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[SimplePage2View alloc] initWithNibName:@"SimplePage2View" bundle:nil]];
// Add Page 3
- [self.pagedScrollView addPagedViewController:[[[SimplePage3View alloc] initWithNibName:@"SimplePage3View" bundle:nil] autorelease]];
+ [self.pagedScrollView addPagedViewController:[[SimplePage3View alloc] initWithNibName:@"SimplePage3View" bundle:nil]];
}
- (void)viewDidUnload
@@ -41,7 +41,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];
}
switch (indexPath.row) {
case kSimpleRow:
@@ -65,19 +65,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
case kSimpleRow: {
SimplePagesView *detailViewController = [[SimplePagesView alloc] initWithNibName:@"SimplePagesView" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
- [detailViewController release];
break;
}
case kOrientationReadyRow: {
OrientationReadyPagesView *detailViewController = [[OrientationReadyPagesView alloc] initWithNibName:@"OrientationReadyPagesView" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
- [detailViewController release];
break;
}
case kVisualsControlsReadyRow: {
VisualsReadyView *detailViewController = [[VisualsReadyView alloc] initWithNibName:@"VisualsReadyView" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
- [detailViewController release];
break;
}
default:
Oops, something went wrong.

0 comments on commit 4457494

Please sign in to comment.