{"action":"created","issue":{"url":"https://api.github.com/repos/swisspol/XLFacility/issues/11","labels_url":"https://api.github.com/repos/swisspol/XLFacility/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/swisspol/XLFacility/issues/11/comments","events_url":"https://api.github.com/repos/swisspol/XLFacility/issues/11/events","html_url":"https://github.com/swisspol/XLFacility/issues/11","id":57983848,"number":11,"title":"Enhancement request - exposing Macros to Swift","user":{"login":"nickvelloff","id":885369,"avatar_url":"https://avatars.githubusercontent.com/u/885369?v=3","gravatar_id":"","url":"https://api.github.com/users/nickvelloff","html_url":"https://github.com/nickvelloff","followers_url":"https://api.github.com/users/nickvelloff/followers","following_url":"https://api.github.com/users/nickvelloff/following{/other_user}","gists_url":"https://api.github.com/users/nickvelloff/gists{/gist_id}","starred_url":"https://api.github.com/users/nickvelloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickvelloff/subscriptions","organizations_url":"https://api.github.com/users/nickvelloff/orgs","repos_url":"https://api.github.com/users/nickvelloff/repos","events_url":"https://api.github.com/users/nickvelloff/events{/privacy}","received_events_url":"https://api.github.com/users/nickvelloff/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swisspol/XLFacility/labels/enhancement","name":"enhancement","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-17T21:19:48Z","updated_at":"2015-02-17T22:10:40Z","closed_at":null,"body":"Hello again!\r\n\r\nJust want to request the exposure of the macros (or re-implementation) to Swift to reduce the unneeded code clutter. \r\n\r\nI attempted the below type of approach from SO but there is a bit of complexity in the macros i'm not familiar with. If they could be \"wrapped\" instead of re-implementing then a single code base could be maintained. \r\n\r\nAnyway though I would ask. Either way enjoying the lib so thanks for sharing it.\r\n\r\nhttp://stackoverflow.com/questions/24133695/how-to-use-objective-c-code-with-define-macros-in-swift\r\n\r\n.h file:\r\n\r\n#define AD_SIZE CGSizeMake(320, 50)\r\n+ (CGSize)adSize;\r\n.m file:\r\n\r\n+ (CGSize)adSize { return AD_SIZE; }\r\nAnd in Swift:\r\n\r\nSince this is a class method you can now use it almost as you would the #define. If you change your #define macro - it will be reflected in the new method you created In Swift:\r\n\r\nlet size = YourClass.adSize()What I did is to create a class method that returns the #define.\r\n\r\nExample:\r\n\r\n.h file:\r\n\r\n#define AD_SIZE CGSizeMake(320, 50)\r\n+ (CGSize)adSize;\r\n.m file:\r\n\r\n+ (CGSize)adSize { return AD_SIZE; }\r\nAnd in Swift:\r\n\r\nSince this is a class method you can now use it almost as you would the #define. If you change your #define macro - it will be reflected in the new method you created In Swift:\r\n\r\nlet size = YourClass.adSize()"},"comment":{"url":"https://api.github.com/repos/swisspol/XLFacility/issues/comments/74765530","html_url":"https://github.com/swisspol/XLFacility/issues/11#issuecomment-74765530","issue_url":"https://api.github.com/repos/swisspol/XLFacility/issues/11","id":74765530,"user":{"login":"nickvelloff","id":885369,"avatar_url":"https://avatars.githubusercontent.com/u/885369?v=3","gravatar_id":"","url":"https://api.github.com/users/nickvelloff","html_url":"https://github.com/nickvelloff","followers_url":"https://api.github.com/users/nickvelloff/followers","following_url":"https://api.github.com/users/nickvelloff/following{/other_user}","gists_url":"https://api.github.com/users/nickvelloff/gists{/gist_id}","starred_url":"https://api.github.com/users/nickvelloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickvelloff/subscriptions","organizations_url":"https://api.github.com/users/nickvelloff/orgs","repos_url":"https://api.github.com/users/nickvelloff/repos","events_url":"https://api.github.com/users/nickvelloff/events{/privacy}","received_events_url":"https://api.github.com/users/nickvelloff/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T22:10:40Z","updated_at":"2015-02-17T22:10:40Z","body":"Sounds good.\n\nWhat I was asking for actually was just an example of a static inline function in Obj-C so I can try to access it from Swift. Swift to my knowledge does not directly support it but may be able to access it through the “header bridge” which is how i’m using XLFacility in my Swift project.\n\nSorry for confusion.\n\n\n\n> On Feb 17, 2015, at 12:03 PM, Pierre-Olivier Latour <notifications@github.com> wrote:\n> \n> You don't need to modify XLFacility for this: I suggest you try directly using static inline functions in a random C header from Swift and see what happens.\n> \n> Also be aware that I don't code in Swift and am only superficially familiar with the language, so it's going to be a long time before I can look at this (months for sure).\n> \n> —\n> Reply to this email directly or view it on GitHub <https://github.com/swisspol/XLFacility/issues/11#issuecomment-74764237>.\n> \n\n"}}