Re: how to slim down view controllers?
Re: how to slim down view controllers?
- Subject: Re: how to slim down view controllers?
- From: Michael Crawford <email@hidden>
- Date: Wed, 01 Apr 2015 06:07:56 -0700
I need to slim down mine as well.
Read the book "Refactoring" by Martin Fowler.
I'm not real sure how to proceed with mine; it grew organically.
Michael David Crawford, Consulting Software Engineer
email@hidden
http://www.warplife.com/mdc/
Available for Software Development in the Portland, Oregon Metropolitan
Area.
On Wed, Apr 1, 2015 at 5:59 AM, Juan Felipe Alvarez Saldarriaga
<email@hidden> wrote:
> Hi,
>
> How you guys slim down your view controllers?, sometimes you end up implementing a lot of protocols in your view controller, so there's a lot of code inside the controller itself. Reading about how to slim down view controllers in iOS I found that a common way is to move DataSources (http://www.objc.io/issue-1/lighter-view-controllers.html) to other class, but what about other delegates?, or if you create views by code?. First, I think about move each delegate to a NSObject class, so I try this:
>
> self.locationManager.delegate = [[FRRYPetDescriptionViewControllerLocationDelegate alloc] init];
>
> Then I ask in IRC and somebody suggest categories, so this is what I got so far:
>
> // FRRYPetDescriptionViewController.h
> @interface FRRYPetDescriptionViewController : UIViewController
>
> @property (nonatomic) CLLocationManager *locationManager;
>
> @property (nonatomic) TPKeyboardAvoidingScrollView *scrollView;
> @property (nonatomic) UIView *contentView;
>
> @end
>
> // FRRYPetDescriptionViewController+Protocols.h
> @interface FRRYPetDescriptionViewController (Protocols) <UITextViewDelegate, UIActionSheetDelegate, MFMailComposeViewControllerDelegate, UIGestureRecognizerDelegate, MKMapViewDelegate, UIViewControllerTransitioningDelegate, CLLocationManagerDelegate>
>
> @end
>
> // FRRYPetDescriptionViewController+UIAdditions.h
> @interface FRRYPetDescriptionViewController (UIAdditions)
>
> - (void)createScrollView;
> - (void)createContentView;
>
> @end
>
> // FRRYPetDescriptionViewController+Callbacks.h
> @interface FRRYPetDescriptionViewController (Callbacks)
>
> @end
>
> // FRRYPetDescriptionViewController+LocationAdditions.h
> @interface FRRYPetDescriptionViewController (LocationAdditions)
>
> @end
>
> This makes me think, what about "private" methods?, do I need to declare all properties in the view controller header file?. What you guys think about this approach or there's some common pattern to follow to not end with a fat controller?.
>
> Thank you.
>
> --
> Juan Felipe Alvarez Saldarriaga
> http://juan.im
> Twitter: @nebiros
> Google Talk: email@hidden
> Skype: jfasaldarriaga
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden