0

我发现SugarRecord库可以替代我在 Objective-C 中使用的 MagicalRecord。

我的项目使用 Swift 作为主要语言。我已经通过可可豆荚添加了 SugarRecord 库,现在当我尝试实现此代码时:

func coreDataStorage() -> CoreDataDefaultStorage {
    let store = CoreData.Store.Named("posts-db")
    let bundle = NSBundle(forClass: CoreDataDefaultStorageTests.classForCoder())
    let model = CoreData.ObjectModel.Merged([bundle])
    let defaultStorage = try! CoreDataDefaultStorage(store: store, model: model)

    return defaultStorage
  }

Xcode 在这里抛出错误:/Users/amatrosov/Documents/projects/Project-Name/Project-Name/NewProgramService.swift:18:29: Use of undeclared type 'CoreDataDefaultStorage'

4

1 回答 1

0

我使用了这个pod "SugarRecord/CoreData",如果您需要更多框架,您也可以使用另一个。

在我想使用一些 SugarRecord 函数的文件中,我添加了以下几行:

import SugarRecord
import CoreData 
于 2016-09-12T10:47:30.447 回答