Swizzling Not Working in a framework

旧巷老猫 提交于 2019-12-25 06:36:16

问题


I'm developing an iOS framework and need to write a swizzling method (for viewDidAppear method in UIViewController).

My swizzling method works perfectly in my application. But when I cut/paste my header+implementation files to my framework and launch the app, it doesn't work. I put an NSLog inside the load method but it doesn't print anything.

For swizzling, I followed this tutorial: http://spin.atomicobject.com/2014/12/30/method-swizzling-objective-c/ I added my "UIViewController+Logging.h" inside the public headers.

Any idea why it doesn't work?


回答1:


Thats because your category is not loaded automatically when the app starts. See this question : Objective-C categories in static library



来源:https://stackoverflow.com/questions/32207470/swizzling-not-working-in-a-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!