草庐IT

reflect.Value

全部标签

ios - alamofire post 方法中的 response.result.value 为 nil

letparametersDictionary=["email":"name@gmail.com","password":"password"]Alamofire.request("http://nanosoftech.com/store/user_check",method:.post,parameters:(parametersDictionaryasNSDictionary)as?Parameters,encoding:JSONEncoding.default,headers:nil).responseJSON{responseinprint("response:",respon

IOS FoodTracker 教程 : Value of tuple type '()' has no member 'path'

我正在完成IOSSwift教程“FoodTracker”,但是有一个错误我可以找到解决方案,但我不明白哪里出了问题以及如何解决它:错误:Valueoftupletype'()'hasnomember'path'此错误在以下代码中针对变量“Meal.ArchiveUrl.path”显示。我的代码,在MealtableViewController(相当于IOS教程):privatefuncsaveMeals(){letisSuccessfulSave=NSKeyedArchiver.archiveRootObject(meals,toFile:Meal.ArchiveUrl.path)if

ios - Obj-C 框架返回 nil,并使我的 Swift 代码崩溃并显示 'fatal error: unexpectedly found nil while unwrapping an Optional value'

我正在使用用Obj-C编写的第三方框架,它有一个功能:-(NSError*)generateModelForm如果此方法成功,它将返回nil。如果它不返回nil,它将返回一个错误,您可以检查该错误以进行调试。现在,当我使用桥接头在我的Swift文件中调用此函数并执行所有必需的操作时,它总是在第一行崩溃并显示“fatalerror:在展开可选值时意外发现nil”我的Swift代码:ifleterror=object.generateModelForm(){println("Error:\(error)")}else{println("Successfullygeneratedmodelf

ios - 如何在 swift 中使用 Key Value Observer?

为了我的目的,我设置了AVFoundation来拍照,我想确保在保存imagedata之前完成曝光和白平衡(adjustingExposure,adjustingWhiteBalance)的调整。否则第一张照片会显得很暗。如何设置键值观察器以在值更改后运行代码?以及如何/在哪里是启动它的最佳地点? 最佳答案 在你得到图像后用didSet创建一个var并且那个var保存图像例如varimage:UIImage{//orwhattypeyourimageis,MabyNSData,butI'mnotsuredidSet{//adjust

ios - UIButton 中的 Swift 3D Touch Force Value

如何测量应用于UIButton功能的3D触摸力?我想用它来快速更改AVAudioPlayer属性的音量。 最佳答案 您可以为所有UIView类\子类使用识别3D触摸的东西自定义类classcustomButton:UIButton{overridefunctouchesMoved(touches:Set,withEventevent:UIEvent?){fortouchintouches{print("%Touchpressure:\(touch.force/touch.maximumPossibleForce)");}}overr

swift - 如何反射(reflect)从其他属性到 Interface Builder 中的属性的更改

我的目标是创建一个像UISlider这样的自定义View。在我的自定义View中,我使用IBDesignable和IBInspectable使其显示在InterfaceBuilder中。如果您在InterfaceBuilder中查看UISlider:您可以看到,如果我将其Value更改为大于其Maximum,Maximum会自动更新其在InterfaceBuilder中的值。我的问题是:当我在InterfaceBuilder中更改其他属性(如Value)的值时,如何使一个属性(如Maximum)更改其值?提前致谢!编辑:这是我当前的实现:当前结果:您可以看到当Minimum值发生变化时

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 - 为什么我得到 "entity X is not key value coding-compliant"?

当我运行以下代码时:letsaveAction=UIAlertAction(title:"Save",style:.default){[unownedself]actioninguardlettextField=alert.textFields?.first,letmapName=textField.textelse{return}varnewCoordinate=NSEntityDescription.insertNewObject(forEntityName:"Coordinates",into:managedObjectContext)varnewMap=NSEntityDesc

ios - 核心数据 : Error - entity is not key value coding-compliant ID

当我尝试保存Group>Contact之间的关系时,我有核心数据错误我通过hashUser从coredata中获取一个联系人,通过uid获取一个组并尝试使用func添加关系to-many//extensionCXDMContactfuncaddGroup(value:CXDMGroup){letitems=self.mutableSetValueForKey("groups");items.addObject(value)}当我尝试保存它时,我得到了异常(exception)CoreData:error:Seriousapplicationerror.Exceptionwascaugh

json - 元组类型 '(key: String, value: AnyObject)' 的值没有成员 'subscript'

我收到这样的错误:元组类型“(键:字符串,值:AnyObject)”的值没有成员“下标”我尝试在线搜索,但我不明白,它总是说要将其更改为字典数组,但是当我将数据解析为[[String:AnyObject]]时,它给了我一个错误。ErrorScreenshot这是我的上下文代码`////MapViewViewController.swift//OntheMap!////CreatedbyBelalElsiesyon11/13/17.//Copyright©2017ElsiesyIndustries.Allrightsreserved.//importUIKitimportMapKitcl