Gaurav
Gaurav

Reputation: 334

Cannot call value of non-function type '((AnyClass) -> Bool)!'

here is my code.

    let myDeepLinkAction: UAAction = UAAction(block: {(args:UAActionArguments, handler:UAActionCompletionHandler) -> Void in
                            handler(UAActionResult.empty())
                            }, acceptingArguments: {(arguments: UAActionArguments) in

                                if arguments.situation == UASituation.backgroundPush {

                                    return true
                                }
                                return ((arguments.value! as AnyObject).isKind(of: NSString) || (arguments.value! as AnyObject).isKind(of: URL))

                        })

that type error is coming after swift version conversion 2.2 to 3.0,pls give me solution as possible.

Upvotes: 2

Views: 833

Answers (3)

Ahmed
Ahmed

Reputation: 31

I was having this issue when I updated to swift 3 in xcode 8

for view in subViews {
 if ((view as AnyObject).isKind(of : UIScrollView))
 {
            scrollView = view as? UIScrollView
        }

It was showing error "Cannot call value of non-function type '((AnyClass) -> Bool)!" Then I added this "classForKeyedArchiver()" for view in subViews {

               if ((view as AnyObject).isKind(of : 
        UIScrollView().classForKeyedArchiver!))

            {

                            scrollView = view as? UIScrollView
           }

Thanks a lot,it worked for me.

Upvotes: 0

Vkharb
Vkharb

Reputation: 886

Make use of classForKeyedArchiver property

For eg : If you want to find out if a view controller belongs to a certain class , use the following snippet

if sampleController.isKind( of : listOfFlowersViewController.classForKeyedArchiver()!)
{

//your success code here

}

Upvotes: 0

Gaurav
Gaurav

Reputation: 334

I have found the solution,its simple

 let myDeepLinkAction: UAAction = UAAction(block: {(args:UAActionArguments, handler:UAActionCompletionHandler) -> Void in
                        handler(UAActionResult.empty())
                        }, acceptingArguments: {(arguments: UAActionArguments) in

                            if arguments.situation == UASituation.backgroundPush {

                                return true
                            }
                            return (arguments.value! is NSString || arguments.value! is URL)

                    })

return (arguments.value! is NSString || arguments.value! is URL)

Upvotes: 1

Related Questions