AYRealmer 库 - 是一个包装器,它允许您仅与模型而不是 Realm-entities 进行交互。
AYRealmer 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
inhibit_all_warnings!
target 'YOUR_TARGET_NAME' do
use_frameworks!
pod 'AYRealmer'
end
// 'AYRConfiguration' - enum that confirm to protocol 'AYDataBaseConfiguration' (configuration).
// 'User' - struct that confirm to protocol 'AYRealmConvertibleModel' (model).
// 1. Create 'AYRealmer' object with configuration and file location
var realmer = AYRealmer(with: AYRConfiguration.user, in: .documents)
// 2. Prepare 'User' object for saving
var user = User()
user.email = "[email protected]"
user.fullName = "Tester User"
// 3. Store 'User' object
realmer.add(model: user)
// 4. Fetch & print 'User' objects
let users: [User] = realmer.objects()
print(users)
// 5. Remove 'User' object
realmer.remove(model: user)
许可
AYRealmer 采用了 MIT 许可。更多信息请参阅 LICENSE 文件。