Topics

Design Pattern Help Needed


Rick Aurbach
 

I have what must be a common problem, and am looking for some architectural suggestions.
 
Over the years, I've built custom objects (e.g., popup calendars, button menus, etc) which have now been added to iOS as of iOS 14. This presents a problem for me, because I want my apps to support pre-14 systems. What I want to implement is:
 
> An @IBDesignable object which implements a custom class on pre-14 systems, but implements the new iOS-14 objects on 14+.
 
> The object must compile and build with a deployment target of 12.0. Obviously this means that I need to use @available and #available to make the link work.
 
> I expect to use adaptor (wrapper) patterns to present a common external API that is iOS-version independent.
 
BUT, I can't figure out how to make this happen. I have some thoughts about making the @IBDesignable class a proxy for an implementation class (which is factory-constructed in the proxy's init methods). The implementation object would be intalled as a subview of the proxy object so all UI would go to it. But I'm sure I'm not thinking of all of the potential issues here.
 
Have you done something similar to this? Can you give any help or advice about such an undertaking before I sit down and get mired in code? (Maybe even a design pattern to share?)
 
Any help would be welcome.
 


Alex Zavatone
 

On Aug 28, 2020, at 12:55 PM, Rick Aurbach via groups.io <rlaurb=me.com@groups.io> wrote:

I have what must be a common problem, and am looking for some architectural suggestions.

Over the years, I've built custom objects (e.g., popup calendars, button menus, etc) which have now been added to iOS as of iOS 14. This presents a problem for me, because I want my apps to support pre-14 systems. What I want to implement is:

An @IBDesignable object which implements a custom class on pre-14 systems, but implements the new iOS-14 objects on 14+.
The object must compile and build with a deployment target of 12.0. Obviously this means that I need to use @available and #available to make the link work.
Check Objective-C headers in teh foundation classes. In there, you can see how you can declare a function’s availability to certain OS versions. Once you see how Apple does it in Objective-C, you can also check out the Swift headers and branch to the functions you want to in your wrapper.

Cheers.

Alex Zavatone