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 protected]
Skype: jfasaldarriaga

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to