草庐IT

invoke_result

全部标签

swift - "data.map(Result.success)"是如何工作并返回一种类型的 Result<Data, Error> 的?

我在thistutorial中偶然发现了以下代码我不知道data.map(Result.success)的返回值是如何工作的。到目前为止,我知道.map在闭包中使用$0。在这种情况下,仅提供Result.success。Result类型调用的返回值如何?classDataLoader{funcrequest(_endpoint:Endpoint,thenhandler:@escaping(Result)->Void){guardleturl=endpoint.urlelse{returnhandler(.failure(NError.invalidURL))}leturlSession

ios - 最新的 ReactiveCocoa Carthage 错误 : No such module 'Result'

我正在将我的项目更新到Swift5Xcode10.3。在最新的ReactiveCocoa10.0.0中,以前的Swift版本一切正常已经尝试过:删除和更新所有carthage删除derivedData文件夹,清理并构建 最佳答案 Swift在版本5中将自己的Result类型添加到标准库中。因此,ReactiveSwiftremoveditsdependencyonthethird-partyResultlibraryithadpreviouslyused,并提供这些说明来更新您的代码:IfyouhaveusedResultonlya

swift - 尝试调整 sknode 的大小会产生错误 "Cannot assign to the result of this expression"?

我创建了一个名为level的SKNode子类,我试图更改它的大小,但是我收到错误“无法分配给该表达式的结果”。我做错了什么?classLevel:SKNode{overrideinit(){super.init()self.frame.size=CGSizeMake(width:100,height:100)//Cannotassigntotheresultofthisexpression 最佳答案 frame属性是只读的,如您在SKNode.h中所见@property(SK_NONATOMIC_IOSONLY,readonly)C

Swift:更新并出现错误: "cannot invoke '! =' with argument list of type.."

在Xcodebeta5中一切都很好,但现在在成熟的Xcode中,我的AppDelegate中出现了2个类似的错误:“无法使用类型为‘(NSManagedObjectContext,NilLiteralConvertible’)的参数列表调用‘!=’”“无法使用类型为‘(NSPersistentStoreCoordinator,NilLiteralConvertible’)的参数列表调用‘!=’”我尝试将!=替换为!==,但出现了不同的错误。我不明白!=有什么问题。代码:funcsaveContext(){varerror:NSError?=nilletmanagedObjectCont

swift - Pinterest-iOS 2.3 和 Swift : calling createPinWithImageURL results in EXC_BAD_ACCESS

使用Pinterest-IOSSDK(2.3)我在通过SwiftBridge创建SDK的实例然后调用createPinWithImageURL时收到EXC_BAD_ACCESS错误。当将相同的代码转换回objective-c,然后从Swift调用包装器方法时,它按预期工作。根本原因似乎是将appID和后缀字符串从Swift传递到Objective-C。此代码失败:self.pinterest=Pinterest(clientId:"your_app_id",urlSchemeSuffix:"prod")!if(pinterest.canPinWithSDK()){pinterest.c

mybatis报错Error attempting to get column ‘id‘ from result set. Cause: org.postgresql.util.PSQLExcept

mybatis报错Errorattemptingtogetcolumn‘id’fromresultset.Cause:org.postgresql.util.PSQLException:Badvaluefortypeint:493987884173376\n;1、事件起因:公司变更原本的自增id转成snowid,但是在测试过程中出现了一个select语句报错了,代码无变更,报错的内容大致是接收的对象不应该使用id来接收,因为数据库变更后是个bigint,正常得拿long来接收,但是问题是sql查询的确实有id,可是接收的对象类中是没有id字段的,正常不会接收这个id参数才对。对象类和sql贴在

IOS- swift : OrPredicate in CloudKit results in invalid

我有这个位来检索两个用户之间的所有消息:letuser1="john"letuser2="mark"letpredicateUser1To2=NSPredicate(format:"user1==%@",user1)letpredicateUser2From1=NSPredicate(format:"user2==%@",user2)letpredicateUser2To1=NSPredicate(format:"user2==%@",user1)letpredicateUser1From2=NSPredicate(format:"user1==%@",user2)letpredica

ios - 如何摆脱警告 "Result of call ' resignFirstResponder( )' is unused"?

自从我将我的代码转换为Swift3后,每当我不使用UITextField的resignFirstResponder()方法。没有错误(至少目前是这样),但我真的不喜欢这样的警告。所以我的问题:我真的应该使用这种调用的结果吗?如果答案是肯定的,我应该如何处理它们?如果答案是否定的:我怎样才能摆脱这些警告? 最佳答案 正如ShaggyD所说,可以安全地忽略此警告。如果您根本不想在项目中看到它们,您可以在BuildSettings中将GCC_WARN_UNUSED_VALUE设置为false/NO。或者在resignFirstRespon

ios 快速解析 : methods with async results

当我转到viewController时,我在我的viewDidAppear方法中调用一个函数:overridefuncviewDidAppear(animated:Bool){getLessons()}此方法从parse.com加载我想在pickerView中使用的数据列表。函数本身:funcgetLessons(){varquery=PFQuery(className:"Lesson")query.orderByAscending("name")query.findObjectsInBackgroundWithBlock{(objects:[AnyObject]!,error:NSE

swift : Cannot invoke 'filter' with an argument list of type '(@noescape (Int) throws -> Bool)'

我遇到了这个错误:funccompactCoords(coords:[Int])->[Int]{returncoords.filter({(value)->Boolinreturnvalue!=0})}无法使用类型为“(@noescape(Int)throws->Bool)”的参数列表调用“filter”感谢您的帮助! 最佳答案 您的代码在Xcode7.1中运行良好。您可能不小心尝试在Xcode6.x中运行此代码?你可以像这样缩短你的函数:funccompactCoords(coords:[Int])->[Int]{returnco