草庐IT

variable-declaration

全部标签

ios - 升级到 Xcode 7 会在 CoreData 模型上创建 "Missing current version declaration"警告

想我会在此处发布针对已知错误的完整问题/答案:当从以前的版本升级到Xcode7(稳定版/测试版)时,您的构建突然给您一个新的警告:“缺少当前版本声明”用于您的CoreData模型文件。最糟糕的是,双击此警告没有任何效果,并且Xcode中没有关于解决方案的明显提示。你是如何解决这个问题的? 最佳答案 注意:这是在Xcode6.4和Xcode7beta3上测试的-从Xcode7beta4开始,似乎有一个内置解决方案,手动创建文件不再有效-请参阅已接受的答案打开终端,导航到您的项目目录和模型文件-您的命令应如下所示:cd/Users/YO

tcp - 错误 : ‘TCP_NODELAY’ was not declared in this scope

我正在尝试在Ubuntu16.04中编译ChatSciptv7.55。但是当我使用makeserver命令时,我得到了这个错误:evserver.cpp:Infunction‘intsettcpnodelay(int)’:evserver.cpp:263:40:error:‘TCP_NODELAY’wasnotdeclaredinthisscopereturnsetsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(void*)&on,sizeof(on));^Makefile:110:recipefortarget'evserver.o'failedmake:**

swift - 已经声明的变量显示 'variable used before declaration'

我“修复”了之前的一个错误,但这样做最终导致它在我明确声明时显示“在声明之前使用了变量“答案””。代码有什么问题?ifoperation.text=="/"{identifyVal()varanswer:Float=0.0//declaredthevalueofansweranswer=round(Float(randomNumber)/Float(randomNumber2))}varanswer:UInt32ifoperation.text=="+"{answer=randomNumber+randomNumber2//nothingwrong}ifoperation.text==

ios - Swift 4 : Variable 'value' inferred to have type 'Void' , 这可能是意想不到的?

我正在尝试将存储在firebase存储中的图像的下载URL保存在数据库中。我看过here,和here,但是我收到以下错误:Cannotconvertvalueoftype'Void'totype'[String:String]'incoercion这发生在下面指示的行上:storageRef.downloadURL{(url,error)inguardletdownloadURL=urlelse{//Uh-oh,anerroroccurred!return}//databaseintegrationletref=Database.database().reference()letuse

swift - 错误 : Variable with getter/setter cannot have an initial value

如何修复此错误?Variablewithgetter/settercannothaveaninitialvalue这是我的代码:functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{varcell:UITableViewCell=tableview.dequeueReusableCellWithIdentifier("cell")asUITableViewCell{//Errorcell.textLabel?.text=self.items[ind

variables - 通过引用访问变量

我正在尝试找出在Swift中引用简单类型的基本方法。在C中,这不是问题:inta=42;int*refA=&a;*refA=43;//Atthispoint,ais43在Swift中,我似乎不能这样做。vara:Int=42println(a)//varaRef:Int=&a//Nope.//varaRef:Int&=&a//Nah.//inoutvar:IntaRef=&a//Nyet//varinout:IntaRef=&a//Non//varaRef:Int*=&a//Whatareyou,stupid,orstubborn?////aRef=43//Ifanyoftheabov

ios - 删除 NotificationCenter 的观察者 - "Variable used within its own initial value"

我不明白如何使用block删除通知的观察者。varblock=NotificationCenter.default.addObserver(forName:.notifName,object:obj,queue:OperationQueue.current,using:{notificationinNotificationCenter.default.removeObserver(block)//Dostuff})这会出现编译器错误“变量在其自身的初始值内使用”。我怎样才能删除这个观察者? 最佳答案 编译器提示是因为它“不知道”闭包

ios - swift 3 : How to assign variable of different option types without multiple if let statements?

首先,如果标题含糊不清,我深表歉意。请随意更改它以符合问题描述。我会尽力描述我的问题,但首先这里有一段代码:ifletvc=currentVCas?FirstViewController{vc.doSameMethod()}elseifletvc=currentVCas?SecondViewController{vc.doSameMethod()}elseifletvc=currentVCas?ThirdViewController{vc.doSameMethod()}基本上,我使用iflet语句检查可选的nil,然后解包并赋值。我在所有3个ViewController中都有doSam

swift WKWebView : Can't find variable error when calling method

我正在尝试将GPS坐标传递给方法调用setIOSNativeAppLocation。我在下面有以下代码,但出现此错误:AJavaScriptexceptionoccurred"UserInfo={WKJavaScriptExceptionLineNumber=1,WKJavaScriptExceptionMessage=ReferenceError:Can'tfindvariable:setIOSNativeAppLocation,WKJavaScriptExceptionSourceURL=http://mywebsite.com,NSLocalizedDescription=AJa

json - 错误 : Expected declaration, 使用未声明的类型 'Object',使用未声明的类型 'JSON'

开始在我的iOS应用程序中集成ObjectMapper以将对象映射到实体。但是出现错误Errors:Expecteddeclaration,Useofundeclaredtype'Object',Useofundeclaredtype'JSON' 最佳答案 如果您是ObjectMapper1.2.0及更高版本,则需要Xcode7.3 关于json-错误:Expecteddeclaration,使用未声明的类型'Object',使用未声明的类型'JSON',我们在StackOverflow