{"action":"created","issue":{"url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/3","repository_url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze","labels_url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/3/comments","events_url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/3/events","html_url":"https://github.com/Draveness/iOS-Source-Code-Analyze/issues/3","id":150856123,"number":3,"title":"Objective-C 中 load 方法的问题","user":{"login":"HaloWang","id":7344724,"avatar_url":"https://avatars.githubusercontent.com/u/7344724?v=3","gravatar_id":"","url":"https://api.github.com/users/HaloWang","html_url":"https://github.com/HaloWang","followers_url":"https://api.github.com/users/HaloWang/followers","following_url":"https://api.github.com/users/HaloWang/following{/other_user}","gists_url":"https://api.github.com/users/HaloWang/gists{/gist_id}","starred_url":"https://api.github.com/users/HaloWang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaloWang/subscriptions","organizations_url":"https://api.github.com/users/HaloWang/orgs","repos_url":"https://api.github.com/users/HaloWang/repos","events_url":"https://api.github.com/users/HaloWang/events{/privacy}","received_events_url":"https://api.github.com/users/HaloWang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-25T13:20:22Z","updated_at":"2016-04-25T13:49:42Z","closed_at":null,"body":"[神奇的 BlocksKit （二）- UITextField+BlocksKit 分类和 load 方法](https://github.com/Draveness/iOS-Source-Code-Analyze/blob/master/BlocksKit/%E7%A5%9E%E5%A5%87%E7%9A%84%20BlocksKit%20%EF%BC%88%E4%BA%8C%EF%BC%89.md#uitextfieldblockskit-分类和-load-方法)\r\n\r\n> 为什么在 load 方法中调用这两个方法？原因有两个：\r\n\r\n> - 该方法只会调用一次，减少了调用的次数\r\n> - 该方法只会在文件被引用的时候调用，减少了不必要的动态代理注册等一系列步骤\r\n\r\n什么叫做『在文件被引用的时候调用』啊？\r\n好像是所有被编译的 Category 都会调用一次的吧？\r\n而且 Category 不用引用`.h`，只要`SomeClass+CategoryName.m`被编译了，就会调用 Category 中实现的`+load`方法啊？\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/comments/214336719","html_url":"https://github.com/Draveness/iOS-Source-Code-Analyze/issues/3#issuecomment-214336719","issue_url":"https://api.github.com/repos/Draveness/iOS-Source-Code-Analyze/issues/3","id":214336719,"user":{"login":"Draveness","id":6493255,"avatar_url":"https://avatars.githubusercontent.com/u/6493255?v=3","gravatar_id":"","url":"https://api.github.com/users/Draveness","html_url":"https://github.com/Draveness","followers_url":"https://api.github.com/users/Draveness/followers","following_url":"https://api.github.com/users/Draveness/following{/other_user}","gists_url":"https://api.github.com/users/Draveness/gists{/gist_id}","starred_url":"https://api.github.com/users/Draveness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Draveness/subscriptions","organizations_url":"https://api.github.com/users/Draveness/orgs","repos_url":"https://api.github.com/users/Draveness/repos","events_url":"https://api.github.com/users/Draveness/events{/privacy}","received_events_url":"https://api.github.com/users/Draveness/received_events","type":"User","site_admin":false},"created_at":"2016-04-25T13:49:42Z","updated_at":"2016-04-25T13:49:42Z","body":"一般与 load 进行比较的方法都是 initialize, 这里没有进行说明，因为这种文章太多了\r\n\r\n> There are two methods that are automatically invoked by the Objective-C runtime for each class. +load is sent when the class is initially loaded, while +initialize is called just before the application calls its first method on that class or an instance of that class. Both are optional, and are executed only if the method is implemented.\r\n> Because method swizzling affects global state, it is important to minimize the possibility of race conditions. +load is guaranteed to be loaded during class initialization, which provides a modicum of consistency for changing system-wide behavior. By contrast, +initialize provides no such guarantee of when it will be executed—in fact, it may never be called, if that class is never messaged directly by the app.\r\n\r\n[Method Swizzling](http://nshipster.com/method-swizzling/)\r\n"}}