nicklockwood / iRate

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#irate
Other
4.1k stars 734 forks source link

Crash when sending `window` message to `UIApplicationDelegate` #311

Open MrMage opened 6 years ago

MrMage commented 6 years ago

Line 857 of iRate.m currently contains this code:

UIViewController *topController = [UIApplication sharedApplication].delegate.window.rootViewController;

However, the window property of the UIApplicationDelegate is declared as optional. Thus, the above code leads to a crash when my application delegate does not implement the window method.

I suggest checking for existence of that method via -respondsToSelector: first and using [UIApplication sharedApplication].keyWindow otherwise.