草庐IT

Swift-Mailer

全部标签

swift - 歧义使用 'fetch' 错误

我在Xcode8.0上使用SWIFT3.0我正在尝试遍历通过模板创建的获取结果。letrequest=model.fetchRequestTemplate(forName:"template")do{letresult=trycontext.fetch(request!)//Erroronthislineforitem:EntityClassNameinresult!{...}}catch{...}我收到错误“'fetch'的使用不明确”。我的方法错了吗?如果是这样,循环获取结果的正确方法是什么? 最佳答案 您正在使用的方法fetc

swift - 在 Swift 中,没有办法获取返回函数的参数名称?

当一个函数的返回值是另一个函数时,无法获取返回函数的参数名称,这是swift语言的陷阱吗?例如:funcmakeTownGrand(budget:Int,condition:(Int)->Bool)->((Int,Int)->Int)?{guardcondition(budget)else{returnnil;}funcbuildRoads(lightsToAdd:Int,toLights:Int)->Int{returntoLights+lightsToAdd}returnbuildRoads}funcevaluateBudget(budget:Int)->Bool{returnbu

ios - 错误代码 2500 Facebook 在 Swift 3.0 上登录

我正在尝试使用swift3.0将Facebook登录集成到iOS10应用程序中。在将FacebookSDK设置到应用程序后,我收到如下所示的错误代码2500:控制台错误代码:body={error={code=2500;"fbtrace_id"=FpAkfsaBAFc;message="Anactiveaccesstokenmustbeusedtoqueryinformationaboutthecurrentuser.";type=OAuthException;};};code=400;}})loginViewController上的loginButton函数:funcloginBut

ios - Swift 3. NSFetchRequest 属性ToFetch

在Swift3中,当我们使用NSFetchRequest时,我们必须指定NSFetchRequestResult。但是如何获取一组属性值呢?如果我使用这样的东西letfetchRequest=NSFetchRequest(entityName:"MyClass")fetchRequest.propertiesToFetch=["myAttributeName"]当我尝试执行提取请求时发生异常。错误:-executeRequest:遇到异常=数据库似乎已损坏。如果我删除带有propertiesToFetch的一行,我不会收到任何错误,但我会得到一个对象数组,而不是属性。

ios - Swift 3 UITableViewDataSource 选择器

更新到Swift3后,我在以下代码中遇到错误:extensionMyViewController:UITableViewDataSource{//...functableView(_tableView:UITableView,heightForRowAtindexPath:IndexPath)->CGFloat{returnsomeValue}}Objective-Cmethod'tableView:heightForRowAt:'providedbymethod'tableView(_:heightForRowAt:)'doesnotmatchtherequirement'ssele

ios - Swift 3.0 无法从 UITableView 中删除一行

我正在使用Xcode8和swift3。当我尝试从UITableView中删除一行时遇到断言失败。Assertionfailurein-[UITableView_endCellAnimationsWithContext:],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.5/UITableView.m:1610Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'Invalidupdate:inv

ios - swift 3 : Cannot automatically unwrap optional before setting it to Label

这个问题在这里已经有了答案:Swift3incorrectstringinterpolationwithimplicitlyunwrappedOptionals(1个回答)关闭6年前。我是iOS开发新手。我通过观看视频教程来完成这个项目,他们使用的是早期版本的Swift,但我使用的是Swift。我遇到了这个问题。两个可选的整数在用于计算时被展开。但是当文本被赋予标签时,它并没有展开。当文本被提供给标签并且它起作用时,我试图再次打开它们。为什么它表现得很奇怪?varleftNumber:Int!varrightNumber:Int!funcgenerateProblem(){leftNu

swift - 这是在 Swift 中使用 get 和 set 的正式正确方法吗?

例如,我想制作某种单选按钮,它会跟踪其事件状态并在其状态更改时更改颜色。我希望它在我设置值时改变颜色。这就是我将如何实现它:classTagButton:UIButton{var_active:Bool=falsevaractive:Bool{set(newVal){_active=newValif(!newVal){self.backgroundColor=UIColor.white//inactive}else{self.backgroundColor=UIColor.red//active}}get{return_active}}}现在,我看到一些问题提出了类似的方法,但令我困扰

swift - 迁移到 swift 3

我正在尝试迁移到swift3。我已经用最新版本更新了podfile用swift3编写的库。我已经更新了cocoapods提到的Alamofirehere.我已经运行了podinstall和podupdate我已经清理了构建文件夹并执行了项目清理。对于Alamofire,我仍然不断收到DependencyAnalysisError。此外,即使我已经更新了pod,我也会继续让目标中的pod框架进行转换。请注意,我已经成功地将我的源代码转换为swift3。 最佳答案 如果在xcode8中使用swift3,在build设置中,将使用旧版Sw

swift - 当样式类制作圆形图像时图像消失

classRoundImage:UIImageView{overridefuncawakeFromNib(){super.awakeFromNib()setupView()}...funcsetupView(){self.layer.borderWidth=borderWidthself.layer.borderColor=borderColorself.clipsToBounds=clipself.layer.cornerRadius=self.frame.size.width/2}overridefuncprepareForInterfaceBuilder(){super.prep