1

For instance in this big project I'm working on there is a "global" header file with #Defines to URLs. I cant use those in swift, but for clarity I want to have the swift alternative in the same .h file so if one is ever changed it should be obvious to change the other.

I was hoping with some compiler magic, this might be possible.

Gagan Singh
  • 988
  • 12
  • 22
  • [Using Swift with Cocoa and Objective-C](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html) – Robert Harvey Jun 25 '14 at 15:57
  • [Interacting with Objective C API's](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-XID_26) – Robert Harvey Jun 25 '14 at 15:58

2 Answers2

2

Don't use #define -- instead use constants.

Constants in Objective-C

You can access Objective-C constants from Swift (using a bridging header)

Community
  • 1
  • 1
Lou Franco
  • 87,846
  • 14
  • 132
  • 192
1

You cannot. You can use them in the same project though.

Using Swift with Cocoa and Objective-C

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
  • ah bummer, I've looked through the apple docs and didn't find anything related to my question, so I wasn't too hopeful – Gagan Singh Jun 25 '14 at 16:05