Realm: Migrating from ObjC to Swift

点点圈 提交于 2021-02-10 12:54:18

问题


I have an app written in ObjC. I've chosen Realm as my DataBase.

I would like to start migrating some parts of my app to Swift.

When getting to Realm I get confused.

There are two pods. From what I understood from the docs, RealmSwift is for pure Swift projects, right?

But, is it possible to migrate model classes to Swift without the RealmSwift pod?


回答1:


As I understand it, Realm Swift isn't exclusive for pure Swift projects, but if you do use it in an iOS app, you can't make any calls to it from any Objective-C code. So if you plan to move all of your Realm code to Swift, then it should be okay.

If you've still got any Realm code in Objective-C, then it would be better to stick with the Realm Objective-C framework, and make any Swift calls via the Swift bridging header.

Realm files are very platform independent, so if you simply rewrote the Objective-C model classes in Swift, as long as the model properties and types were exactly the same, it should still simply work.



来源:https://stackoverflow.com/questions/36961251/realm-migrating-from-objc-to-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!