草庐IT

multi-context-coredata

全部标签

swift - Vapor Swift 流利 : Type of expression is ambiguous without more context

这是我的路线:router.get("answers","delete",Int.parameter){req->FutureinletanswerID=tryreq.parameters.next(Int.self)guardlet_=getUsername(req)else{throwAbort(.unauthorized)}returnMessage.query(on:req).filter(\.id==answerID).first().map(to:Response.self){answeringuardletanswer=answerelse{throwAbort(.not

objective-c - Swift CoreData DictionaryResultType 转换

在下面的代码中,我使用CoreData来获得不同的结果:request.propertiesToFetch=NSArray(objects:"docID","docName")request.resultType=NSFetchRequestResultType.DictionaryResultTyperequest.returnsDistinctResults=truevardistinctResults:NSArray=context.executeFetchRequest(request,error:nil)println(distinctResults)这是println()的

ios - 核心数据 : should I be fetching objects from the parent context or does the child context have the same objects as the parent?

我对ManagedObjectContext的父/子上下文有点困惑。当我设置子上下文并设置父上下文时,子上下文是否包含父上下文的所有对象?我正在使用在AppDelegate中创建的常用CoreData方法,但我将ConcurrencyQueue更改为main。在我应该更新数据库的方法中:创建子上下文,设置父上下文对子上下文执行阻塞从父上下文中获取在子上下文中创建或更新对象在子上下文中调用保存有通知监听器来处理子上下文保存保存父上下文我的问题是,看起来我没有将任何内容保存到子上下文中。我没有收到Update或CreateChatMessage的println消息。我在这里做错了什么?Ap

ios - swift 3.0 : Unable to infer closure type in the current context , PromiseKit

我在swift3.0中有以下代码,我在其中使用PromiseKit。funccalculateTravelTime(from:CLLocation,to:CLLocation)->Promise{Promise{completion,reject->Voidinletrequest=MKDirections.Request()request.transportType=.walkingletfromPlacemark=MKPlacemark(coordinate:from.coordinate)lettoPlacemark=MKPlacemark(coordinate:to.coord

objective-c - 如何在 Xcode 8 中使用 CoreData?

我正在尝试使用CoreData,但是当我将它添加到我的项目时,我只获得了两个新方法:-(NSPersistentContainer*)persistentContainer和-(void)saveContext现在我无法使用旧方法来处理CoreData,而且我找不到任何有关这些新方法和Objective-C的教程。我如何在带有Objective-c的Xcode8中使用persistentContainer从CoreData保存和获取数据? 最佳答案 您可以获取上下文为-letcontext=(UIApplication.shared

ios - adjustsFontSizeToFitWidth 或 boundingRectWithSize 何时更改 context.actualScaleFactor?

什么时候NSStringDrawingContext的actualScaleFactor会改变?Thedocumentationsays:“如果您在minimumScaleFactor属性中指定了自定义值,则当绘制完成时,此属性包含用于绘制字符串的实际比例因子值。”我的代码:myButton.titleLabel!.font=UIFont(name:"AmericanTypewriter-Bold",size:40)myButton.titleLabel?.adjustsFontSizeToFitWidth=truemyButton.setTitle("\(textString)",f

xcode - Swift 构建 CoreData,语义问题

我有一个Swift-ObjectiveC/C++项目,一切正常,直到我添加了CoreData,现在每次我修改某些东西时,它都会抛出一个错误:/.../DerivedData/.../Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/-Swift.h:136:26:Cannotfindinterfacedeclarationfor'NSManagedObject',superclassof'';didyoumean'NSManagedObjectModel'?和/.../DerivedData/.../Int

swift - Coredata 的 CodeGen 'manual/none + create NSManagedObject subclass' 与 'category/extension' 之间的功能差异是什么

我读过SubclassingNSManagedObjectwithswift3andXcode8beta和this很棒的教程。还有一些问题。相同点是:我可以随心所欲地自定义这两个类。我可以添加新属性或删除或重命名属性。即对于category/extension它将在新构建时得到更新(在派生数据中),而对于manual/none它将保持类文件完整并更新文件导航中的扩展名,即我不会以重复文件结束。这一切都由Xcode处理,因为它们标有预处理器@NSManaged不允许将类似@NSManagedpublicvarname:String?的内容直接转储到现有的NSManagedObject子类

core-data - 在 CoreData 中保存 Swift CLLocation

我试图在CoreData中保存CLLocation数据。我的属性设置为Transformable对象。那里的一些示例代码表明可以使用转换为NSValue的对象来保存位置数据。CLLocationCoordinate2DmyLocation;NSValue*locationValue=[NSValuevalueWithBytes:&myLocationobjCType:@encode(CLLocationCoordinate2D)]//thenputlocationValueintostorage-maybeanObjCcollectionclassorcoredataetc.从数据存储

ios - 获取对象时无法访问一对多 CoreData 关系

我创建了一个数据模型,我有一个任务。这个任务有几个变量,但也有一个与事件的一对多链接。这些事件可能是添加图片或评论之类的事情,因此一项任务可能有很多事件。我已将它们链接起来,如下所示:实体文件也已设置:importCoreDataclassTask:NSManagedObject{@NSManagedvararea:Area@NSManagedvarpictures:[TaskPicture]@NSManagedvarevents:[Event]@NSManagedvarrequestedByDept:NSString?@NSManagedvarrequestedByUser:NSSt