草庐IT

static_check

全部标签

swift - 在 Swift 中,是否可以从结构中获取所有 **static** 属性?

我有一个带有类似协议(protocol)的结构protocolPage{funcgetAllProperties()->[String:Any]}extensionPage{publicfuncgetAllProperties()->[String:Any]{varresult:[String:Any]=[:]letmirror=Mirror(reflecting:self)print(mirror)for(labelMaybe,valueMaybe)inmirror.children{print(labelMaybe)guardletlabel=labelMaybeelse{cont

swift - 为什么总是在 Swift 协议(protocol)中使用 static 关键字作为类型属性要求的前缀?

在TheSwiftProgrammingLanguage一书的第369页,它说“在协议(protocol)中定义类型属性要求时,始终使用static关键字作为前缀。”示例代码:protocolAnotherProtocol{staticvarsomeTypeProperty:Int{getset}}这样做的原因或好处是什么? 最佳答案 因为没有static关键字,您最终声明的是实例属性而不是类型属性。紧跟在您引用的段落之后的示例显示了这一点:Here’sanexampleofaprotocolwithasingleinstancep

xcode - 带有 Objective-C 选择器 'setChecked' 的方法 'setChecked:' 与具有相同 Objective-C 选择器的 'checked' 的 setter 冲突

我创建了继承自UIButton的自定义类。在那个类中我创建了一个定义为的函数:funcsetChecked(checked:Bool){self.checked=checkedifchecked{buttonImageView.image=UIImage(named:"radioSelected.png")}else{buttonImageView.image=UIImage(named:"radioUnselected.png")}}在我将我的xCode更新到6.1.3之前它工作正常。现在我不断在函数定义行收到错误消息:Method'setChecked'withObjective-

ios - 新的 Lister 应用程序错误 "The shared application group container is unavailable. Check your entitlements and provisioning profiles for this target..."

我已经完成了自述文件中的所有内容。仍然在我按下播放键后,模拟器运行然后崩溃并显示以下消息:在第175行处失败:lettoURL=ListUtilities.localDocumentsDirectory.URLByAppendingPathComponent(url.lastPathComponent)我不知道该怎么办。 最佳答案 您必须将LISTER_BUNDLE_PREFIX更改为您公司的捆绑ID,例如“com.yourcompany.com”,并最终修复AppGroup选项和iCloud选项中的错误。第一步必须在第2步和第3步

swift - swift 中 struct static func 与 class static func 之间的区别?

我无法找到classstaticfunction与structstaticfunction之间的任何区别。据我所知,类静态函数不能被继承,结构也没有继承选项。Pleasedonotgetconfusedbystaticfuncandclassfuncinclass.classa{staticfuncmyMethod1(){}}对比structa{staticfuncmyMethod1(){}} 最佳答案 这有点牵强,但由于class和struct类型的引用与值语义,分别在实现如果提供了类型的实例,您希望使用类型方法(static)来

ios - 使用未解析的标识符 'Static'

我已经更新了xcode8.0swift3,我发现了很多错误。这是其中之一:Useofunresolvedidentifier'Static'这是我在以前的版本xcode7.3.1swift2中创建和工作的类。importUIKitenumFONTSIZE:Int{casesizesmall=1casesizesbig=2casesizemedium=3}classsizeFont:NSObject{privatestaticvar__once:()={Static.instance=sizeFont()}()classfuncgetSize(_enumFont:FONTSIZE)->C

swift - iOS 核心蓝牙 : startAdvertising() Error advertising static data

我想发布静态数据。我在iOS上使用Swift2.2.1和CoreBluetooth。我的应用构建蓝牙Services及其相应的Characteristics,然后调用startAdvertising(),peripheralManagerDidStartAdvertising90回调返回此错误:peripheralManagerDidStartAdvertisingencounteredanerror.//MineOneormoreparameterswereinvalid.//...fromAppleCoreBluetoothnil//...returnvaluefromAppleC

Java 锁 : How equality check for Monitor locks is done in synchronized block?

当你在一个对象上有几个synchronizedblock时(比如说)obj那么Java如何检查所有这些obj是否是相同还是不同?例如:publicstaticf(){synchronized("xyz"){...}}如果上面的函数f被两个线程同时调用,它们会阻塞另一个吗?请注意,每个线程都会获得一个新的String对象实例。为了检查这一点,我编写了以下测试代码,看起来上面的block确实可以工作,但是还有其他意想不到的结果。publicclassTest{publicstaticvoidmain(String[]args){newThread(){publicvoidrun(){//f

java - 为什么 `private static` 字段在 Java 8 接口(interface)中是不允许的?

当我尝试编译以下代码时publicinterfaceSomeInterface{privatestaticLoggerlogger=Logger.getLogger();publicdefaultvoidsomeMethod(){logger.info("someMethod:defaultimplementation");}}我得到一个错误IllegalmodifierfortheinterfacefieldSomeInterface.logger;onlypublic,static&finalarepermitted当我删除private修饰符时,代码会编译,但我不希望包中的其他类

java - 将 checkstyle/google_checks.xml 与 maven-checkstyle-plugin 一起使用时出错

我正在尝试使用checkstylesgoogle_checks.xml与maven-checkstyle-plugin.如果我将google_checks.xml与最新的checkstyleintelliJ插件一起使用,一切都是正确的,但是当我尝试通过maven-checkstyle插件配置它时,我收到此错误:[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-checkstyle-plugin:2.13:check(default-cli)onprojectXX_XX_XX:Failedduringcheckstyleco