mrackwitz / MRProgress

Collection of iOS drop-in components to visualize progress
MIT License
2.55k stars 306 forks source link

UINavigationController delegate crashes #27

Closed stephencelis closed 10 years ago

stephencelis commented 10 years ago

+[MRNavigationBarProgressView progressViewForNavigationController:] wraps the navigation controller delegate (if set), at runtime, with an MRMessageInterceptor. If, however, the delegate is set to something else after this occurs, the MRMessageInterceptor instance is deallocated and can cause crashes when accessed.

Probably want to hook into methods via swizzling instead of juggling delegates around to avoid this.

mrackwitz commented 10 years ago

Yeah, you're right. As there is even no warning about this danger documented, this is a bad idea. I try to avoid method swizzling, as it feels not like a solution, more then a workaroud... and it has potential to introduce a lot more side-effects... but sometimes it's the last resort. Probably we could use KVO or NSNotificationCenter instead.

stephencelis commented 10 years ago

NSNotificationCenter or KVO's definitely the way to go if it's possible. Didn't know offhand if there were notifications or observable keys for the hooks.

mrackwitz commented 10 years ago

See #28. :wink: