草庐IT

date_accessed

全部标签

ios - 为什么 SKProductsRequestDelegate/SKRequestDelegate didFailWithError 在 NSError 上抛出 EXC_BAD_ACCESS?

我使用SKProductsRequest从AppStore下载产品信息。当我在我的设备上测试连接丢失时,请求失败,但是当我尝试NSLog错误时,我的应用程序在SKRequestDelegate内崩溃:我做错了什么?另一件令我好奇的事情是,ExpressionInspector能够显示NSError.debugDescription...它在第一次请求时失败,因此不存在与多次使用productRequest变量相关的可能错误(这是我的swift类中的强引用)。 最佳答案 我终于找到原因了。它与SKProductsRequest无关!我

swift - 删除类型信息时类型删除: do we risk non-reversibly losing access to kept-alive data of the instance of the erased type,?

考虑以下常见的简单类型删除方案protocolFoo{associatedtypeBarfuncbar()->Bar}structAnyFoo:Foo{privatelet_bar:()->Barinit(_foo:F)whereF.Bar==Bar{_bar=foo.bar/*storesareferencetofoo.bar,sofookeptalivebyARC?*/}funcbar()->Bar{return_bar()}}假设上面的初始化参数foo是(打算成为)“大”类型的临时实例,我们只对从中切出Foo蓝图的信息感兴趣(即bar()方法)。structHuge{/*...*

ios - CloudKit iOS 10 错误 : Account doesn't have access to CloudKit account

出于某种原因,一小部分iOS10用户无法从我的公共(public)iCloud容器中读取数据。CloudKit返回的localisedError是“Accountdoesn'thaveaccesstoCloudKitaccount”,但是在网上搜索后,我找不到任何提及此错误的信息。有没有人知道什么会导致这种情况?下面的示例代码示例。letsortDescriptor=NSSortDescriptor.init(key:"Version",ascending:false)letpublicDatabase=CKContainer(identifier:"iCloud.blah.blah.

swift - 为什么具有两个 `as Date` 对象的 `timeIntervalSince()` 需要 `NSDate`?

我有一个NSManagedObject对象:@NSManagedpublicvartimestamp:NSDate我需要两者之间的时间间隔,所以我实现了:letinterval=next.timestamp.timeIntervalSince(current.timestamp)为什么会出现以下错误?'NSDate'isnotimplicitlyconvertibleto'Date';didyoumeantouse'as'toexplicitlyconvert?我很惊讶,因为next和current都是NSDate类型,而timeIntervalSince()是NSDate方法。按照错

ios - MTLBuffer 内容导致 EXC_BAD_ACCESS

我创建了一个由浮点值数组填充的缓冲区。不幸的是,当我尝试查询其contents()属性时(当我试图调试问题时),我得到了EXC_BAD_ACCESS。这是代码:letinputData=[Float32](repeatElement(5,count:16384))//Declaration//Declarationofthebufferandfillingcontents...inputBuffer=device.makeBuffer(bytes:inputData,length:MemoryLayout.size*inputData.count,options:MTLResource

ios - 如何禁用 "named colours can only be accessed from an Asset Catalog in iOS 11.0 and later"警告?

我收到以下警告YouaretargetingiOS9.0,butnamedcolourscanonlybeaccessedfromanAssetCataloginiOS11.0andlater我只在已经有if#available(iOS11.0,*)的情况下使用命名颜色,所以这个警告是无用的。如何仅禁用此警告?我不想摆脱所有构建时或Assets目录警告,只是特别想摆脱这个警告。 最佳答案 遗憾的是,在Xcode9中,无法再消除Swift项目中的特定警告。您只能使所有与Assets目录相关的警告静音,但您的问题表明您不希望那样。我同意

ios - 如何在 Swift 4 中将 Any 转换为 Date?

我从服务器收到一个日期://ItcomesfromserverasAnylet.letuserInfo:[AnyHashable:Any]letuserInfoDic=userInfoasNSDictionaryuserInfoDic.value(forKey:"gcm.notification.date")asAny//printsOptional(2018-04-26)如果我尝试转换为日期,则会抛出错误:‘Any?’isnotconvertibleto'Date';didyoumeantouse'as!'toforcedowncast?当我强制执行时,返回一个fatalerror。

EXC_BAD_ACCESS 中的 Swift 泛型方法

我对泛型和swift中的泛型方法很着迷。为什么这段使用Swift泛型方法的代码在调用method1时给出EXC_BAD_ACCESS?您可以使用Playground对其进行测试。importUIKitimportFoundationprotocolSomeProtocol{funcprintMe()}classSomeClass:SomeProtocol{letvalue:Stringinit(value:String){self.value=value}funcprintMe(){print("\(value)")}}classBaseClass{funcmethod1(_param

ios - appdelegate 在 shouldPerformSegueWithIdentifier 之前的 exc_bad_access

我有一个从点击按钮到ViewController的转折点。在包含按钮的ViewController的swift类中:overridefuncshouldPerformSegueWithIdentifier(identifier:String,sender:AnyObject!)->Bool{returntrue}当我运行模拟器并单击按钮时,我在AppDelegate类上收到EXC_BAD_ACCESS错误。如果我删除该方法,则不会发生此错误。谢谢 最佳答案 您必须为您的segue分配Identifer如果直接从按钮连接segue:在

date - Parse.com — 在 Swift 中使用日期对象查询

我数据库中的一个解析对象有一个日期字段。我想使用用户选择的日期作为查询。query.whereKey("dateFieldParse",equalTo:janFirst)我不确定如何设置这个“janFirst”字段。我知道它必须以某种方式格式化以进行解析检索,但这种格式是什么。我尝试在NSDate对象中设置组件,但它似乎不起作用。letuserCalendar=NSCalendar.currentCalendar()letjanFirstComponent=NSDateComponents()janFirstComponent.year=2014janFirstComponent.mo