{"action":"created","issue":{"url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/2","labels_url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/2/comments","events_url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/2/events","html_url":"https://github.com/netcosports/objective-c-style-guide/pull/2","id":127008793,"number":2,"title":"Constants","user":{"login":"netcosportsanatoly","id":13415149,"avatar_url":"https://avatars.githubusercontent.com/u/13415149?v=3","gravatar_id":"","url":"https://api.github.com/users/netcosportsanatoly","html_url":"https://github.com/netcosportsanatoly","followers_url":"https://api.github.com/users/netcosportsanatoly/followers","following_url":"https://api.github.com/users/netcosportsanatoly/following{/other_user}","gists_url":"https://api.github.com/users/netcosportsanatoly/gists{/gist_id}","starred_url":"https://api.github.com/users/netcosportsanatoly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netcosportsanatoly/subscriptions","organizations_url":"https://api.github.com/users/netcosportsanatoly/orgs","repos_url":"https://api.github.com/users/netcosportsanatoly/repos","events_url":"https://api.github.com/users/netcosportsanatoly/events{/privacy}","received_events_url":"https://api.github.com/users/netcosportsanatoly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-16T07:46:31Z","updated_at":"2016-01-16T08:33:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/netcosports/objective-c-style-guide/pulls/2","html_url":"https://github.com/netcosports/objective-c-style-guide/pull/2","diff_url":"https://github.com/netcosports/objective-c-style-guide/pull/2.diff","patch_url":"https://github.com/netcosports/objective-c-style-guide/pull/2.patch"},"body":"Constants declared as `difine`s can be used in compile-time string concatenation. Example:\r\n\r\n```objc\r\n#define BaseCompanyName @\"Netcosports\"\r\n#define EuropeCompanyName BaseCompanyName @\" Europe\"\r\n```\r\n\r\nYou can olso write:\r\n\r\n```objc\r\nNSLog(@\"Company name is \" BaseCompanyName);\r\n```\r\n\r\nFor number constanst `define` form is also convinient, because they also can be appended to string and can be converted to `NSNumber` in compile time. Example:\r\n\r\n```objc\r\n#define thumbnailHaight 44\r\nNSArray* array = @[@thumbnailHeight];\r\n```\r\n\r\nForm of `static` constanst doesn't have any conviniences and have one great defect:\r\nEvery object file, that imports header with such constant, will have own local copy of it. It will be great memory hit, if such constant will be imported in .pch file."},"comment":{"url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/comments/172172965","html_url":"https://github.com/netcosports/objective-c-style-guide/pull/2#issuecomment-172172965","issue_url":"https://api.github.com/repos/netcosports/objective-c-style-guide/issues/2","id":172172965,"user":{"login":"netcosportsanatoly","id":13415149,"avatar_url":"https://avatars.githubusercontent.com/u/13415149?v=3","gravatar_id":"","url":"https://api.github.com/users/netcosportsanatoly","html_url":"https://github.com/netcosportsanatoly","followers_url":"https://api.github.com/users/netcosportsanatoly/followers","following_url":"https://api.github.com/users/netcosportsanatoly/following{/other_user}","gists_url":"https://api.github.com/users/netcosportsanatoly/gists{/gist_id}","starred_url":"https://api.github.com/users/netcosportsanatoly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netcosportsanatoly/subscriptions","organizations_url":"https://api.github.com/users/netcosportsanatoly/orgs","repos_url":"https://api.github.com/users/netcosportsanatoly/repos","events_url":"https://api.github.com/users/netcosportsanatoly/events{/privacy}","received_events_url":"https://api.github.com/users/netcosportsanatoly/received_events","type":"User","site_admin":false},"created_at":"2016-01-16T08:33:42Z","updated_at":"2016-01-16T08:33:42Z","body":"String `@\"Company name is \" BaseCompanyName` will be created at compile time, you will not spent processor time for formatting. But it's just a feature. With `define` you can write and `NSLog(@\"Company name is %@\", BaseCompanyName);` if you like.\r\n\r\n`extern` form actually needed only for frameworks.\r\nIt's ok for strings. But not so good for numbers: numbers will loose ability to make calculations at compile time and one side effect of that, is that they can't be used as array's sizes.\r\n\r\n\r\n"}}