草庐IT

storage_type

全部标签

swift - "Cannot assign value of type ' 整数 ' to type ' 单位 ' "

letexpdate=NSUserDefaults.standardUserDefaults().objectForKey("expiration")as!NSDateletcalendar=NSCalendar.currentCalendar()letcomponents=calendar.components([.Day,.Month,.Year],fromDate:expdate)vartheyear=components.yearvarthemonth=components.monthstripCard.expMonth=themonthstripCard.expYear=th

ios - Swift:无法将类型 'Item?' 的值分配给类型 'Item?.Type'

我有一个名为Item的类,它具有以下属性:varname:Stringvarphoto:UIImage?vardescription:String?varfavorite:Boolinit方法如下所示:init?(name:String,photo:UIImage?,description:String?,favorite:Bool){guard!name.isEmptyelse{returnnil}self.name=nameself.photo=photoself.description=descriptionself.favorite=favorite}在ViewControll

swift - 'init 不可用 : use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type

由于我将我的代码转换为Swift3,所以发生了错误。'initisunavailable:use'withMemoryRebound(to:capacity:_)'totemporarilyviewmemoryasanotherlayout-compatibletype.这是我的代码:funcparseHRMData(data:NSData!){varflags:UInt8varcount:Int=1varzw=[UInt8](count:2,repeatedValue:0)flags=bytes[0]/*----------------FLAGS----------------*//

ios - swift 2 : Type of expression is ambiguous without more context

classExample:NSObject,UIViewControllerAnimatedTransitioning,UIViewControllerTransitioningDelegate{varaView:UIView!UIView.animateWithDuration(duration,delay:0.0,usingSpringWithDamping:0.8,initialSpringVelocity:0.8,options:nil,animations:{self.aView.transform=CGAffineTransformIdentity//Thislineist

xcode - Swift 编译器错误 : Use of undeclared type 'EKEventStore'

在swift中,我定义了一个类FirstViewController:UIViewController。在文件的开头,我有这个导入:importUIKitimportEventKit在类的方法中,我有这一行:vareventStore:EKEventStore=EKEventStore()我已经导入了EventKit.framework。但我总是遇到这个Swift编译器错误:使用未声明的类型“EKEventStore”。请帮忙! 最佳答案 在DeploymentTarget=8.0的情况下,我必须导入EventKitUI.frame

ios - “type of expression is ambiguous without more context” 使用结构属性作为字典键

我得到异常:typeofexpressionisambiguouswithoutmorecontext使用以下代码:structParameter{staticletEmail="email"staticletPassword="password"staticletIsFacebookUser="isFacebookUser"}letparameters:[String:AnyObject]=[Parameter.Email:email,Parameter.Password:password,Parameter.IsFacebookUser:false]它不接受bool类型,我不想更改

arrays - iOS swift : How to find unique members of arrays of different types based on specific attributes

目标:我有两个不同的类,以及两个包含每个类成员的数组。使用Swift2.0,我想根据每个类的特定属性找到一个数组与另一个数组相比的唯一成员。示例:classA{varname:Stringinit(name:String){self.name=name}}classB{vartitle:Stringinit(title:String){self.title=title}}letaArray=[A(name:"1"),A(name:"2"),A(name:"3"),A(name:"4")]letbArray=[B(title:"1"),B(title:"2"),B(title:"5")]

ios - Firebase 给了我 Use of undeclared type with FIRDatabase and FIRDataSnapshot

从零到应用程序的FirebaseIO示例给我无法定义的错误//Firebaseservicesvardatabase:FIRDatabase!继续//CreateachatmessagefromaFIRDataSnapshotfuncchatMessageFromSnapshot(snapshot:FIRDataSnapshot)->ChatMessage?{letdata=snapshot.valueas!Dictionaryguardletname=data["name"]asString!else{returnnil}guardletmessage=data["message"]

types - 括号内的 Swift 类型

我今天在玩Swift,一些奇怪的类型开始出现:letflip=Int(random()%2)//orarc4random(),orrand();whateveryouprefer如果我在Xcode6(Beta2)中输入flip,自动完成会弹出,并显示flip的类型是(Int)而不是Int。这很容易改变:letflip:Int=Int(random()%2)letflop=random()%2现在flip和flop的类型是Int而不是(Int)进一步研究,这些“括号类型”是可以预测的,您可以通过在变量赋值的任何部分添加额外的括号来实现它们。letg=(5)//becomestype(In

types - arc4random() 的余数运算符和数组的计数导致 "could not find an overload"错误

这段代码varrandomNumber:Int=arc4random()%nameArray.count给我错误“找不到接受所提供参数的‘%’的重载”我仍在努力适应语法并阅读文档,但似乎无法弄清楚这一点。谁能帮忙? 最佳答案 您必须将arc4random()的返回值(CInt)转换为Int:varrandomNumber:Int=Int(arc4random())%nameArray.count 关于types-arc4random()的余数运算符和数组的计数导致"couldnotfin