{"action":"created","issue":{"url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/10","labels_url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/10/comments","events_url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/10/events","html_url":"https://github.com/atljeremy/JFMinimalNotifications/issues/10","id":68681676,"number":10,"title":"Crashes in [JFMinimalNotification configureInitialNotificationConstraintsForTopPresentation:]","user":{"login":"billburgess","id":644761,"avatar_url":"https://avatars.githubusercontent.com/u/644761?v=3","gravatar_id":"","url":"https://api.github.com/users/billburgess","html_url":"https://github.com/billburgess","followers_url":"https://api.github.com/users/billburgess/followers","following_url":"https://api.github.com/users/billburgess/following{/other_user}","gists_url":"https://api.github.com/users/billburgess/gists{/gist_id}","starred_url":"https://api.github.com/users/billburgess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billburgess/subscriptions","organizations_url":"https://api.github.com/users/billburgess/orgs","repos_url":"https://api.github.com/users/billburgess/repos","events_url":"https://api.github.com/users/billburgess/events{/privacy}","received_events_url":"https://api.github.com/users/billburgess/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/labels/investigate","name":"investigate","color":"5319e7"}],"state":"closed","locked":false,"assignee":{"login":"atljeremy","id":1019253,"avatar_url":"https://avatars.githubusercontent.com/u/1019253?v=3","gravatar_id":"","url":"https://api.github.com/users/atljeremy","html_url":"https://github.com/atljeremy","followers_url":"https://api.github.com/users/atljeremy/followers","following_url":"https://api.github.com/users/atljeremy/following{/other_user}","gists_url":"https://api.github.com/users/atljeremy/gists{/gist_id}","starred_url":"https://api.github.com/users/atljeremy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atljeremy/subscriptions","organizations_url":"https://api.github.com/users/atljeremy/orgs","repos_url":"https://api.github.com/users/atljeremy/repos","events_url":"https://api.github.com/users/atljeremy/events{/privacy}","received_events_url":"https://api.github.com/users/atljeremy/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/milestones/2","html_url":"https://github.com/atljeremy/JFMinimalNotifications/milestones/v0.0.3","labels_url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/milestones/2/labels","id":923137,"number":2,"title":"v0.0.3","description":"v0.0.3 of JFMinimalNotifications with performance improvements and additional configuration options.","creator":{"login":"atljeremy","id":1019253,"avatar_url":"https://avatars.githubusercontent.com/u/1019253?v=3","gravatar_id":"","url":"https://api.github.com/users/atljeremy","html_url":"https://github.com/atljeremy","followers_url":"https://api.github.com/users/atljeremy/followers","following_url":"https://api.github.com/users/atljeremy/following{/other_user}","gists_url":"https://api.github.com/users/atljeremy/gists{/gist_id}","starred_url":"https://api.github.com/users/atljeremy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atljeremy/subscriptions","organizations_url":"https://api.github.com/users/atljeremy/orgs","repos_url":"https://api.github.com/users/atljeremy/repos","events_url":"https://api.github.com/users/atljeremy/events{/privacy}","received_events_url":"https://api.github.com/users/atljeremy/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":4,"state":"closed","created_at":"2015-01-06T01:50:12Z","updated_at":"2015-04-17T22:45:13Z","due_on":"2015-01-15T05:00:00Z","closed_at":"2015-04-17T22:45:13Z"},"comments":18,"created_at":"2015-04-15T13:23:04Z","updated_at":"2015-05-01T14:10:41Z","closed_at":"2015-04-17T22:44:36Z","body":"I keep getting a few crashes showing up in my app with some errors.\r\n\r\nFatal Exception: NSInternalInconsistencyException\r\nNSDictionaryOfVariableBindings failed because either one of the values is nil, or there's something wrong with the way the macro is being invoked. Cannot assign value nil for key \"superview\". Keys:( superview, notification )\r\n\r\nIt is coming from the JFMinimalNotifications.m line 239. I'm guessing the superview is nil, but not exactly sure how to recreate it as the number of crashes are pretty small. Opening this issue to see if anyone else is having the same issue or if I'm doing something wrong. My implementation is identical to the example, nothing too flashy. But this has crashed my app a few times and would like to patch it up if possible.\r\n![screen shot 2015-04-15 at 8 22 33 am](https://cloud.githubusercontent.com/assets/644761/7159553/a06c0536-e348-11e4-89f6-5dc1367b4518.png)\r\n"},"comment":{"url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/comments/98141409","html_url":"https://github.com/atljeremy/JFMinimalNotifications/issues/10#issuecomment-98141409","issue_url":"https://api.github.com/repos/atljeremy/JFMinimalNotifications/issues/10","id":98141409,"user":{"login":"atljeremy","id":1019253,"avatar_url":"https://avatars.githubusercontent.com/u/1019253?v=3","gravatar_id":"","url":"https://api.github.com/users/atljeremy","html_url":"https://github.com/atljeremy","followers_url":"https://api.github.com/users/atljeremy/followers","following_url":"https://api.github.com/users/atljeremy/following{/other_user}","gists_url":"https://api.github.com/users/atljeremy/gists{/gist_id}","starred_url":"https://api.github.com/users/atljeremy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atljeremy/subscriptions","organizations_url":"https://api.github.com/users/atljeremy/orgs","repos_url":"https://api.github.com/users/atljeremy/repos","events_url":"https://api.github.com/users/atljeremy/events{/privacy}","received_events_url":"https://api.github.com/users/atljeremy/received_events","type":"User","site_admin":false},"created_at":"2015-05-01T14:10:41Z","updated_at":"2015-05-01T14:10:41Z","body":"@PasqualePuzio @billburgess I've figured this out!\r\n\r\nThe issue is the `dismissalDelay:` parameter in the convenience constructor. When this is set, it creates an `NSTimer` that takes an `NSInvocation` which calls `dismiss` after the specified `dismissalDelay`. The issue is that if the view that you've added the notification to is deallocated before the timer counts down to 0 and calls `invoke` on the `NSInvocation` this crash will occur because the notifications `superview` is now null. Here's the stack trace I get int the Xcode console when reproducing this.\r\n\r\n```\r\n2015-05-01 10:00:48.325 JFMinimalNotification[20297:9693055] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSDictionaryOfVariableBindings failed because either one of the values is nil, or there's something wrong with the way the macro is being invoked.  Cannot assign value nil for key \"superview\". Keys:(\r\n    superview,\r\n    notification\r\n)'\r\n*** First throw call stack:\r\n(\r\n\t0   CoreFoundation                      0x0000000107a6bc65 __exceptionPreprocess + 165\r\n\t1   libobjc.A.dylib                     0x0000000107704bb7 objc_exception_throw + 45\r\n\t2   CoreFoundation                      0x0000000107a6bb9d +[NSException raise:format:] + 205\r\n\t3   Foundation                          0x00000001072adbc0 _NSDictionaryOfVariableBindings + 844\r\n\t4   JFMinimalNotification               0x0000000105c95ccd -[JFMinimalNotification configureInitialNotificationConstraintsForTopPresentation:layoutIfNeeded:] + 557\r\n\t5   JFMinimalNotification               0x0000000105c9572d -[JFMinimalNotification dismiss] + 525\r\n\t6   CoreFoundation                      0x0000000107961dec __invoking___ + 140\r\n\t7   CoreFoundation                      0x0000000107961c42 -[NSInvocation invoke] + 290\r\n\t8   Foundation                          0x00000001072b7744 __NSFireTimer + 83\r\n\t9   CoreFoundation                      0x00000001079d3174 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20\r\n\t10  CoreFoundation                      0x00000001079d2d35 __CFRunLoopDoTimer + 1045\r\n\t11  CoreFoundation                      0x0000000107994d3d __CFRunLoopRun + 1901\r\n\t12  CoreFoundation                      0x0000000107994366 CFRunLoopRunSpecific + 470\r\n\t13  GraphicsServices                    0x000000010a004a3e GSEventRunModal + 161\r\n\t14  UIKit                               0x0000000105f92900 UIApplicationMain + 1282\r\n\t15  JFMinimalNotification               0x0000000105c8debf main + 111\r\n\t16  libdyld.dylib                       0x00000001080b2145 start + 1\r\n)\r\nlibc++abi.dylib: terminating with uncaught exception of type NSException\r\n```\r\n\r\nAs you can see, it's the exact same as the stack traces you both provided me with. So, my solution to address this is going to be simply checking if `superview` is `null` and if so return immediately and don't worry about dismissing the notification since the view that it was attached to is now gone (deallocated).\r\n\r\nI would also highly encourage you both, and anyone else who may come across this thread alter, to check your app for these types of scenarios so that they do not happen. You'll need to make sure you aren't trying to set dismissalDelay's in the notification constructor which may end up firing after the view the notification is attached to is dismissed/deallocated."}}