Some random notes I took while doing bugfixes offline
Why do we even have global reachability?
Corner case, but I was trying to add a “localhost” blog to the simulator while offline, and couldn’t do it
Some users report that they can’t moderate comments in 3.2 since the buttons are disabled. This uses per-blog reachability, but it seems it’s not working ok
UIAlertView best practices:
If you need to show an alert:
- If it’s caused by user action, a local variable is OK
- If you don’t set a delegate (just show a message), a local variable is OK
- If the alert is generated as a response to a background event (e.g. AFNetworking failure block) and you set the delegate to ‘self’ because you want custom behaviour: store the alert view as an instance variable, and clear it’s delegate on dealloc
+ [ReachabilityUtils showAlertNoInternetConnectionWithDelegate:]
I think it’s broken by design: you’re passing an object (usually ‘self’ as a delegate), but you receive no pointer to the object who’s going to have that delegate. So when dealloc happens, it’s impossible to set the delegate to nil
Since it seems it’s never called from a block, we should be fine, but it still could be way better.
Instead of passing a delegate and having to implement the alertView:clickedButtonAtIndex: method (BTW, delegate should have type id if that’s expected), the method could be something like – (void)showAlertNoInternetConnectionWithRetryBlock:(void (^)())retryBlock
We should make a custom WPAlertView to implement “Need Help?”. Most of the code uses [WordPressAppDelegate showAlertViewWithTitle:message: so maybe try to extend that and use it everywhere, since the app delegate is not getting deallocated :)
Move anything not critical to a secondary queue on applicationDidFinishLaunchingWithOptions: (see iTunes connect timeout crash)