lundi 1 décembre 2014

Customising or subclassing a CocoaPod library


Vote count:

0




For example, let's say I'm using a Pod such as http://ift.tt/1cko0ow which has many classes, and I want to customise it's functionality -- where do I start? The obvious way is the edit the code within the Pods project, but I'm pretty sure that's a terrible idea that will end up breaking stuff. I'd like to change very simple things, such as changing what a button on a certain view controller does e.g. segue to one of my view controllers in my own project.


I figure I should be subclassing, so let's say I were to subclass MHGalleryController, the main gallery controller, so that it uses my subclass of MHGalleryImageViewerViewController, which is the view controller for displaying individual images. I first subclass MHGalleryImageViewerViewController to CustomMHGalleryImageViewerViewController and override the relevant method so it does what I want. Since MHGalleryImageViewerViewController is presented through MHGalleryController, I then subclass as CustomMHGalleryController where I now run into trouble -- there are many methods within this class that use MHGalleryImageViewerViewController (which is a property), but I want them to use my own CustomMHGalleryImageViewerViewController. Do I have to override each of these methods and replace all instances of MHGalleryImageViewerViewController with my subclass? Is there a more elegant solution?


Any help to get me started would be greatly appreciated, thanks!



asked 46 secs ago







Customising or subclassing a CocoaPod library

Aucun commentaire:

Enregistrer un commentaire