{"action":"closed","issue":{"url":"https://api.github.com/repos/ChenYilong/iOSInterviewQuestions/issues/34","repository_url":"https://api.github.com/repos/ChenYilong/iOSInterviewQuestions","labels_url":"https://api.github.com/repos/ChenYilong/iOSInterviewQuestions/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/ChenYilong/iOSInterviewQuestions/issues/34/comments","events_url":"https://api.github.com/repos/ChenYilong/iOSInterviewQuestions/issues/34/events","html_url":"https://github.com/ChenYilong/iOSInterviewQuestions/issues/34","id":137993850,"number":34,"title":"第37题有优化","user":{"login":"adronfan","id":6027516,"avatar_url":"https://avatars.githubusercontent.com/u/6027516?v=3","gravatar_id":"","url":"https://api.github.com/users/adronfan","html_url":"https://github.com/adronfan","followers_url":"https://api.github.com/users/adronfan/followers","following_url":"https://api.github.com/users/adronfan/following{/other_user}","gists_url":"https://api.github.com/users/adronfan/gists{/gist_id}","starred_url":"https://api.github.com/users/adronfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adronfan/subscriptions","organizations_url":"https://api.github.com/users/adronfan/orgs","repos_url":"https://api.github.com/users/adronfan/repos","events_url":"https://api.github.com/users/adronfan/events{/privacy}","received_events_url":"https://api.github.com/users/adronfan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-02T21:12:00Z","updated_at":"2016-03-10T03:45:48Z","closed_at":"2016-03-10T03:45:48Z","body":"```\r\n37. 使用block时什么情况会发生引用循环，如何解决？\r\n\r\n一个对象中强引用了block，在block中又使用了该对象，就会发射循环引用。 解决方法是将该对象使用__weak或者__block修饰符修饰之后再在block中使用。\r\n\r\nid weak weakSelf = self; 或者 weak __typeof(&*self)weakSelf = self该方法可以设置宏\r\nid __block weakSelf = self;\r\n```\r\n这里有个优化，“一个对象中强引用了block，在block中又使用了该对象”，block出现循环引用是因为双方的强引用导致的，如果有一方不是强应用，都不会出现循环引用的。所以上面一句话应该改成“一个对象中强引用了block，在block中又强引用了该对象”\r\n解决方案还有一种：\r\n```\r\n打破循环引用，将其中一方强制制空“xxx=nil”。\r\n```"}}