• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using protocol extension to dismiss keyboard on outside tap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using protocol extension to dismiss keyboard on outside tap


  • Subject: Re: Using protocol extension to dismiss keyboard on outside tap
  • From: Devarshi Kulshreshtha <email@hidden>
  • Date: Tue, 19 Apr 2016 11:05:27 +0530

Thanks, I ended doing exactly what you suggested.

On Mon, Apr 18, 2016 at 10:41 PM, Quincey Morris <
email@hidden> wrote:

> On Apr 18, 2016, at 08:48 , Alex Kac <email@hidden> wrote:
>
>
> Protocol extensions are Swift only - not ObjC compatible I believe.
>
>
> You’re right, and I don’t see any direct way of getting around. Alternate
> solutions:
>
> 1. If the “shared” code really is this short:
>
>         private func configureToDismissKeyboard() {
>
>            let tapGesture = UITapGestureRecognizer(target: self,
> action: "hideKeyboard")
>            tapGesture.cancelsTouchesInView = true
>            form.addGestureRecognizer(tapGesture)
>        }
>
>        func hideKeyboard() {
>            form.endEditing(true)
>        }
>
>
> then I don’t see the value in going to any trouble to factor it out of
> multiple classes. I’d recommend just duplicating it in each view
> controller. (Further, ‘configureToDismissKeyboard’ doesn’t really need to
> be a function. Its 3-line body could easily be written inline in
> viewDidLoad.)
>
> Swift tends to produce a desire for over-generalization. In cases where
> the simple approach is a better use of developer time, the desire should be
> resisted. :)
>
> 2. If the actual code is more complicated, I think the problem can be
> solved by a simple “transfer” method in each class:
>
> func hideKeyboard () { doHideKeyboard () }
>
>
> where ‘doHideKeyboard’ is in the protocol and extension in place of
> ‘hideKeyboard’.
>
>


--
Thanks,

Devarshi
_______________________________________________

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


References: 
 >Using protocol extension to dismiss keyboard on outside tap (From: Devarshi Kulshreshtha <email@hidden>)
 >Re: Using protocol extension to dismiss keyboard on outside tap (From: Quincey Morris <email@hidden>)
 >Re: Using protocol extension to dismiss keyboard on outside tap (From: Devarshi Kulshreshtha <email@hidden>)

  • Prev by Date: Re: BOOL parameter passed as nil object
  • Next by Date: Re: Proper way to set up constants when building an iOS framework
  • Previous by thread: Re: Using protocol extension to dismiss keyboard on outside tap
  • Next by thread: Re: Using protocol extension to dismiss keyboard on outside tap
  • Index(es):
    • Date
    • Thread