草庐IT

question_type

全部标签

Swift 2 语法错误 : Cannot call value of non-function type 'Int'

我写了一个函数:extensionString{funcsize()->Int{returncount(self.utf16)}}但它返回一个错误:Cannotcallvalueofnon-functiontype'Int'我该如何解决? 最佳答案 count是swift1.2的方式,在swift2.0中使用myString.characters.count(任何数组都可以这样计算)所以:extensionString{funcsize()->Int{returnself.characters.count}}

ios - 推特搜索 API 1.1 错误 : Could not cast value of type '__NSCFDictionary' to 'NSArray'

此代码用于在Twitter上搜索主题标签,但给出错误提示无法将“__NSCFDictionary”类型的值转换为“NSArray”当我使用以下URL访问我的主页时间线时,相同的代码工作正常https://api.twitter.com/1.1/statuses/home_timeline.jsonfuncgetTimeLine(){letaccountType=account.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)self.account.requestAccessToAccountsWi

swift - 错误 : Protocol requires a nested type '_BitsType' (Swift. 浮点类型)

我试图让我的一个类采用FloatingPointProtocol;我已经实现了显示的所有必需功能here,但是Swift仍然给我以下错误:协议(protocol)需要嵌套类型“_BitsType”(Swift.FloatingPointType)我一直无法找到关于_BitsType及其在FloatingPointType中的嵌套的任何文档。我需要实现什么才能让我的类成功采用FloatingPointType?提前感谢您的帮助! 最佳答案 _BitsType是一种用于表示浮点值的类型“原始位”。定义是publiclyvisiblein

swift - 升级到 swift3 时,出现错误 'cannot override a property with type GKEntity'

更新到swift3后,注释行返回错误:类型为“GKEntity!”的属性“实体”(又名“ImplicitlyUnwrappedOptional”)无法覆盖类型为“GKEntity?”的属性importSpriteKitimportGameplayKitclassEntityNode:SKNode{weakvarentity:GKEntity!//errorhere}升级前一切正常。知道哪里出了问题以及如何解决这个问题吗? 最佳答案 SKNode已经有一个名为entity的属性,其定义如下:varentity:GKEntity?因此你

ios - 错误 : 'Cannot call value of non-function type' on Swift 3

以下代码的第二行和第三行适用于swift2.3,自从我更新到swift3后,我一直收到错误消息无法调用非函数类型的值'Any?!'对于他们两个:letdic=tryJSONSerialization.jsonObject(with:data!,options:JSONSerialization.ReadingOptions.mutableLeaves)as!NSDictionaryletlat=((((dic["results"]asAnyObject).value(forKey:"geometry")asAnyObject).value(forKey:"location")asAny

ios - UITableViewDataSource 导致 libc++abi.dylib : terminating with uncaught exception of type NSException

我有一个包含UITableView的ViewController:importUIKitimportGoogleMapsclassRestaurantMapViewController:UIViewController,UITableViewDataSource,UITableViewDelegate{@IBOutletweakvarmapView:GMSMapView!@IBOutletweakvartableView:UITableView!varcameraPosition:GMSCameraPosition!varzoomLevel:Double=15overridefuncv

swift - xcode8 Alamofire 4更新错误 "use of undeclared type Response"

更新到Xcode8和Alamofire4后,我在代码“ResponseclassFetchData{staticfuncget(_type:T.Type,success:@escaping()->Void,fail:@escaping(_error:NSError)->Void)->VoidwhereT:Mappable,T:Meta{Alamofire.request(type.url(),method:.get).responseArray{(response:Response)in//.responseArray{(response:DataResponse)inswitchre

Swift 3 Oauth2 Imgur 刷新键 - 错误 400 "Invalid grant_type parameter or parameter missing"

我在使用Swift/NSMutableURLRequest调用ImgurAPI的/oauth2/token端点时遇到问题,也许这实际上只是我以错误的方式设置了请求,因为我对NSMutableURLRequest没有太多经验。场景:用户已经验证了我的应用程序,他可以将照片发布到他的Imgur帐户。问题:Imgur要求28天后重新认证。这就是为什么在对应用程序进行身份验证后,您会得到一个(临时的;28天)access_token和一个长期的refresh_token,您可以在28天后使用它来获得一个新的访问token。我按照API调用来检索新的access_token但总是收到错误:“无效

swift - 泛型类型错误 : Cannot explicitly specialise a generic type

我正在尝试在RequestManager中创建一个通用函数通过ServiceManager将服务器接收到的JSON转换为指定类型.这是我的代码:请求管理器:typealiasResultResponseManager=(_data:AnyObject?,_error:ErrorPortage?)->VoidtypealiasSuccessResponseManager=(_success:Bool,_error:ErrorPortage?)->VoidtypealiasobjectBlock=(_object:T?,_error:ErrorPortage?)->Voidextensio

ios - 错误 : Invalid conversion from throwing function of type '(_) throws -> ()' to non-throwing function type '(DataSnapshot) -> Void'

这是我的代码:funcloadData(){ref.child(currentUserID!).observe(.childAdded){(snapshot)inletsnapshotValue=try?snapshot.valueas?[String:AnyObject]ifletitem=tryTableViewModel(id:snapshot.key,likeLabel:self.likeLabel,playLabelString:self.playLabelString,json:snapshotValue){self.items.append(item)}self.tabl