vlasov / CCBottomRefreshControl

MIT License
319 stars 77 forks source link

Protect Method Swizzling from being executed more than once #23

Open thomaskoehn-de opened 8 years ago

thomaskoehn-de commented 8 years ago

I had an issue with CCBottomRefreshControl when running in a test target, where the swizzled method gets called in an endless loop. Further investigation showed that load was called two times with my test target only.

Ultimately, the issue for that was a different one, but nonetheless, the swizzling in the load methods should get protection from being called multiple times.

Please wrap the swizzling in every load in a static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{

Also, consider using JRSwizzle (probably no one should ever re-implement swizzling on their own).