{"action":"created","comment":{"url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/comments/35170079","id":35170079,"diff_hunk":"@@ -31,9 +51,24 @@ public class BPCompatibleAlertController : NSObject, UIAlertViewDelegate {\n     */\n     public var alertViewStyle: UIAlertViewStyle\n     \n+    /**\n+    If this set, when the user dismisses the alert all the resources used\n+    by this alert controller will be automatically released allowing this object to be deallocated.\n+    \n+    After the user has dismissed the alert, presentFrom: cannot be called again on this object.\n+    \n+    Should client code set this to false (because they intend to re-user the alert), it must at some stage call releaseResources() to\n+    ensure internal resources are freed up.\n+    \n+    releaseResourcesWhenAlertDismissed defaults to true.\n+    */\n+    public var releaseResourcesWhenAlertDismissed: Bool = true\n+    \n     private var alertController: UIAlertController!\n-    private var alertView: UIAlertView!\n+    private var alertView: BPAlertView!\n     private var actions: [String : BPCompatibleAlertAction]\n+    private var actionObservers: Array<NSObjectProtocol> = []","path":"BPCompatibleAlertController/BPCompatibleAlertController.swift","position":48,"original_position":48,"commit_id":"46591e0d017928bcf5dd9ce91b3ba1b96cb9dc8f","original_commit_id":"46591e0d017928bcf5dd9ce91b3ba1b96cb9dc8f","user":{"login":"github-user32","id":447669,"avatar_url":"https://avatars.githubusercontent.com/u/447669?v=3","gravatar_id":"","url":"https://api.github.com/users/github-user32","html_url":"https://github.com/github-user32","followers_url":"https://api.github.com/users/github-user32/followers","following_url":"https://api.github.com/users/github-user32/following{/other_user}","gists_url":"https://api.github.com/users/github-user32/gists{/gist_id}","starred_url":"https://api.github.com/users/github-user32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-user32/subscriptions","organizations_url":"https://api.github.com/users/github-user32/orgs","repos_url":"https://api.github.com/users/github-user32/repos","events_url":"https://api.github.com/users/github-user32/events{/privacy}","received_events_url":"https://api.github.com/users/github-user32/received_events","type":"User","site_admin":false},"body":"Sure, consistency is good. You mean to something like this `private var actionObservers: [NSObjectProtocol] = []`? Let me know and I'll update the pull request.","created_at":"2015-07-22T00:19:53Z","updated_at":"2015-07-22T00:19:53Z","html_url":"https://github.com/BayPhillips/compatible-alert-controller/pull/8#discussion_r35170079","pull_request_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/comments/35170079"},"html":{"href":"https://github.com/BayPhillips/compatible-alert-controller/pull/8#discussion_r35170079"},"pull_request":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8","id":38514296,"html_url":"https://github.com/BayPhillips/compatible-alert-controller/pull/8","diff_url":"https://github.com/BayPhillips/compatible-alert-controller/pull/8.diff","patch_url":"https://github.com/BayPhillips/compatible-alert-controller/pull/8.patch","issue_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/8","number":8,"state":"open","locked":false,"title":"Resource management","user":{"login":"github-user32","id":447669,"avatar_url":"https://avatars.githubusercontent.com/u/447669?v=3","gravatar_id":"","url":"https://api.github.com/users/github-user32","html_url":"https://github.com/github-user32","followers_url":"https://api.github.com/users/github-user32/followers","following_url":"https://api.github.com/users/github-user32/following{/other_user}","gists_url":"https://api.github.com/users/github-user32/gists{/gist_id}","starred_url":"https://api.github.com/users/github-user32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-user32/subscriptions","organizations_url":"https://api.github.com/users/github-user32/orgs","repos_url":"https://api.github.com/users/github-user32/repos","events_url":"https://api.github.com/users/github-user32/events{/privacy}","received_events_url":"https://api.github.com/users/github-user32/received_events","type":"User","site_admin":false},"body":"(First of all, thanks very much for making BPCompatibleAlertController public!)\r\n\r\nThis pull request addresses some memory management issues.\r\n\r\nThe existing alert controller instances would never get deallocated by ARC due to internal references to 'self' (eg. NSNotificationCenter observer handler as well as any actions (blocks) that client code might pass in that happen to reference the alert controller instance.) \r\n\r\nThese internal references did have the handy side effect(!) of preventing the iOS 7 crash alluded to in point 1 of the README's To Do section - I've now commented that explicitly in the code to help ensure it doesn't accidentally get removed.\r\n\r\nSo, the bulk of this pull request contains changes to automatically clean up resources after the alert has been dismissed. This is the default mode of operation (assuming that the alert controller instance is only used to present an alert once). If the alert controller needs to present the same alert multiple times, the client code can set a flag to prevent resource cleanup and then the onus on them to manually call the `releaseResources()` member function when they are done.\r\n\r\nThe demo code has been updated along similar lines, and the whole alert controller instance is now a local variable making it:\r\n a) easier to check in the debugger that ARC does indeed deallocate it after the user dismisses the dialog\r\n b) clear that the alert controller can be used without needing to retain a reference to it\r\n\r\nI've also renamed the member variable `isiOS8` to `uiAlertControllerAvailable` which will then continue to make semantic sense come iOS 9.\r\n","created_at":"2015-06-25T05:56:35Z","updated_at":"2015-07-22T00:19:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fdba10e2e2e80801d8e59ee3ab635b16a735997","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8/commits","review_comments_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8/comments","review_comment_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/8/comments","statuses_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/statuses/46591e0d017928bcf5dd9ce91b3ba1b96cb9dc8f","head":{"label":"github-user32:ResourceManagement","ref":"ResourceManagement","sha":"46591e0d017928bcf5dd9ce91b3ba1b96cb9dc8f","user":{"login":"github-user32","id":447669,"avatar_url":"https://avatars.githubusercontent.com/u/447669?v=3","gravatar_id":"","url":"https://api.github.com/users/github-user32","html_url":"https://github.com/github-user32","followers_url":"https://api.github.com/users/github-user32/followers","following_url":"https://api.github.com/users/github-user32/following{/other_user}","gists_url":"https://api.github.com/users/github-user32/gists{/gist_id}","starred_url":"https://api.github.com/users/github-user32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-user32/subscriptions","organizations_url":"https://api.github.com/users/github-user32/orgs","repos_url":"https://api.github.com/users/github-user32/repos","events_url":"https://api.github.com/users/github-user32/events{/privacy}","received_events_url":"https://api.github.com/users/github-user32/received_events","type":"User","site_admin":false},"repo":{"id":38028954,"name":"compatible-alert-controller","full_name":"github-user32/compatible-alert-controller","owner":{"login":"github-user32","id":447669,"avatar_url":"https://avatars.githubusercontent.com/u/447669?v=3","gravatar_id":"","url":"https://api.github.com/users/github-user32","html_url":"https://github.com/github-user32","followers_url":"https://api.github.com/users/github-user32/followers","following_url":"https://api.github.com/users/github-user32/following{/other_user}","gists_url":"https://api.github.com/users/github-user32/gists{/gist_id}","starred_url":"https://api.github.com/users/github-user32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-user32/subscriptions","organizations_url":"https://api.github.com/users/github-user32/orgs","repos_url":"https://api.github.com/users/github-user32/repos","events_url":"https://api.github.com/users/github-user32/events{/privacy}","received_events_url":"https://api.github.com/users/github-user32/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/github-user32/compatible-alert-controller","description":"An iOS7 compatible UIAlertController written in Swift","fork":true,"url":"https://api.github.com/repos/github-user32/compatible-alert-controller","forks_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/forks","keys_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/teams","hooks_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/hooks","issue_events_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/issues/events{/number}","events_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/events","assignees_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/assignees{/user}","branches_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/branches{/branch}","tags_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/tags","blobs_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/statuses/{sha}","languages_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/languages","stargazers_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/stargazers","contributors_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/contributors","subscribers_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/subscribers","subscription_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/subscription","commits_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/contents/{+path}","compare_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/merges","archive_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/downloads","issues_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/issues{/number}","pulls_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/pulls{/number}","milestones_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/milestones{/number}","notifications_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/labels{/name}","releases_url":"https://api.github.com/repos/github-user32/compatible-alert-controller/releases{/id}","created_at":"2015-06-25T05:03:58Z","updated_at":"2015-06-25T05:03:58Z","pushed_at":"2015-07-09T06:11:58Z","git_url":"git://github.com/github-user32/compatible-alert-controller.git","ssh_url":"git@github.com:github-user32/compatible-alert-controller.git","clone_url":"https://github.com/github-user32/compatible-alert-controller.git","svn_url":"https://github.com/github-user32/compatible-alert-controller","homepage":null,"size":126,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"BayPhillips:master","ref":"master","sha":"975378ba6eef6c190afba6db43d3b0ae66d54e0d","user":{"login":"BayPhillips","id":537211,"avatar_url":"https://avatars.githubusercontent.com/u/537211?v=3","gravatar_id":"","url":"https://api.github.com/users/BayPhillips","html_url":"https://github.com/BayPhillips","followers_url":"https://api.github.com/users/BayPhillips/followers","following_url":"https://api.github.com/users/BayPhillips/following{/other_user}","gists_url":"https://api.github.com/users/BayPhillips/gists{/gist_id}","starred_url":"https://api.github.com/users/BayPhillips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BayPhillips/subscriptions","organizations_url":"https://api.github.com/users/BayPhillips/orgs","repos_url":"https://api.github.com/users/BayPhillips/repos","events_url":"https://api.github.com/users/BayPhillips/events{/privacy}","received_events_url":"https://api.github.com/users/BayPhillips/received_events","type":"User","site_admin":false},"repo":{"id":27406067,"name":"compatible-alert-controller","full_name":"BayPhillips/compatible-alert-controller","owner":{"login":"BayPhillips","id":537211,"avatar_url":"https://avatars.githubusercontent.com/u/537211?v=3","gravatar_id":"","url":"https://api.github.com/users/BayPhillips","html_url":"https://github.com/BayPhillips","followers_url":"https://api.github.com/users/BayPhillips/followers","following_url":"https://api.github.com/users/BayPhillips/following{/other_user}","gists_url":"https://api.github.com/users/BayPhillips/gists{/gist_id}","starred_url":"https://api.github.com/users/BayPhillips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BayPhillips/subscriptions","organizations_url":"https://api.github.com/users/BayPhillips/orgs","repos_url":"https://api.github.com/users/BayPhillips/repos","events_url":"https://api.github.com/users/BayPhillips/events{/privacy}","received_events_url":"https://api.github.com/users/BayPhillips/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BayPhillips/compatible-alert-controller","description":"An iOS7 compatible UIAlertController written in Swift","fork":false,"url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller","forks_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/forks","keys_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/teams","hooks_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/hooks","issue_events_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/events{/number}","events_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/events","assignees_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/assignees{/user}","branches_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/branches{/branch}","tags_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/tags","blobs_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/statuses/{sha}","languages_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/languages","stargazers_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/stargazers","contributors_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/contributors","subscribers_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/subscribers","subscription_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/subscription","commits_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/contents/{+path}","compare_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/merges","archive_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/downloads","issues_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues{/number}","pulls_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls{/number}","milestones_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/milestones{/number}","notifications_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/labels{/name}","releases_url":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/releases{/id}","created_at":"2014-12-01T23:50:09Z","updated_at":"2015-07-21T23:43:58Z","pushed_at":"2015-07-09T06:11:59Z","git_url":"git://github.com/BayPhillips/compatible-alert-controller.git","ssh_url":"git@github.com:BayPhillips/compatible-alert-controller.git","clone_url":"https://github.com/BayPhillips/compatible-alert-controller.git","svn_url":"https://github.com/BayPhillips/compatible-alert-controller","homepage":null,"size":303,"stargazers_count":19,"watchers_count":19,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8"},"html":{"href":"https://github.com/BayPhillips/compatible-alert-controller/pull/8"},"issue":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/8"},"comments":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/BayPhillips/compatible-alert-controller/statuses/46591e0d017928bcf5dd9ce91b3ba1b96cb9dc8f"}}}}