Warning while adding and using a new method in external library protocol

后端 未结 3 1449
迷失自我
迷失自我 2021-01-15 09:32

I am using a external library and one of my view controller is registering as delegate for a class in that framework. Now, at one place I want to execute some code on this d

3条回答
  •  一整个雨季
    2021-01-15 09:41

    The property libraryController.delegate is defined in the external library to conform to LibraryDelegate. Try to downcast to MyExtendedDelegate before you call the method from your extended protocol.

    if ([self.libraryController.delegate conformsToProtocol:@protocol(MyExtendedDelegate)])
    {
        id extendedDelegate = (id)self.libraryController.delegate;
        if ([extendedDelegate respondsToSelector:@selector(actionTaken)])
        {
            [extendedDelegate actionTaken];
        }
    }
    

提交回复
热议问题