Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use Realm Objective-C or Realm Swift in my mixed Objective-C / Swift project?

Tags:

ios

swift

realm

My project uses Swift and targets iOS 8.0 and newer, but we use some files from our old Objective-C project, and brings in some Objective-C libraries via CocoaPods. Which Realm interface should I use in this project: Objective-C or Swift? I'm confused because of the announcement in the Realm documentation:

If you’re looking to use Realm from Objective-C, or from mixed Objective-C & Swift apps please see Realm Objective-C instead. Using both Realm Objective-C and Realm Swift simultaneously is not supported.

like image 221
user3488542 Avatar asked Dec 17 '15 07:12

user3488542


1 Answers

They key detail is whether you intend to access your Realm model classes from only Swift, or both Swift and Objective-C. If you will only access them from Swift you can happily use Realm Swift, even if elsewhere in your application you use code written in Objective-C. If you will access your Realm model classes from both Swift and Objective-C code you'll need to use Realm Objective-C rather than Realm Swift.

like image 113
bdash Avatar answered Nov 15 '22 11:11

bdash