草庐IT

multiple-contexts

全部标签

iOS UITabBarController 最佳实践 : one tab one controller or multiple tabs one controller?

我是iOS开发的新手,已经开始使用Swift。我目前正在使用包含3个选项卡/导航的选项卡栏导航。我应该将UIViewController子类化并将其用于所有3个场景,还是每个场景都应该有自己的UIViewController子类。这方面的最佳做法是什么?谢谢。更新感谢@Larcerax和@Adrian的意见,我已经更新了Storyboard:每个选项卡导航都有自己的UINavigationController和UIViewController的子类。如果我对您的指示的理解有误,请告诉我。 最佳答案 如果我是你,并且我以前有过你的经历

Swift for 循环 "Expression type ' [[String : String]]' is ambiguous without more context

我正在尝试从字典数组中访问以下项目,但我遇到了两个问题(都是不同的方法)。字典数组初始化如下:vartestingArray=[[String:String]()]testingArray.append(["name":"Ethiopia","url":"localhost:8088"])testingArray.append(["name":"Bugatti","url":"localhost:8088"])testingArray.append(["name":"Brazil","url":"localhost:8088"])testingArray.append(["name":

ios - Swift 中的 "func observeValueForKeyPath(keyPath : NSString, object : AnyObject, change : NSDictionary, context : Void)"问题

我已经为这样的AVPlayer添加了一个观察者self.audioPlayer.addObserver(self,forKeyPath:"currentItem.status",options:[NSKeyValueObservingOptions.New,NSKeyValueObservingOptions.Initial],context:nil)然后打电话funcobserveValueForKeyPath(keyPath:NSString,object:AnyObject,change:NSDictionary,context:Void){ifobjectas!AVPlayer

ios - 在 iOS 中使用 Core Graphics Context 绘制圆 - Objective-C 或 Swift

我是这样画一个圆的:CGContextRefcontextRef=UIGraphicsGetCurrentContext();CGContextSetLineWidth(contextRef,2.0);//CGContextSetRGBFillColor(contextRef,0,0,1.0,1.0);//CGContextSetRGBStrokeColor(contextRef,0,0,1.0,1.0);CGContextSetStrokeColorWithColor(contextRef,[colorCGColor]);CGRectcirclePoint=(CGRectMake(c

ios - Swift iOS 构建期间的 "clang: error: cannot specify -o when generating multiple output files"

我刚刚使用CocoaPods为我的SwiftiOS项目安装了一个额外的依赖项(HockeyAppSDK),现在我的项目在构建过程中失败并给出错误:clang:error:cannotspecify-owhengeneratingmultipleoutputfiles我卸载了依赖项,但项目在构建过程中仍然失败并出现相同的错误。有想法该怎么解决这个吗?编辑:使用xcodecli构建时,错误如下所示:2015-07-2420:28:09.378xcodebuild[34313:1668414]流错误:偏移量29处的流错误:由不受支持的XCDependencyGraph构建创建以下构建命令失败

ios - swift 中 AppDelegate 和 Context 的作用是什么?

我刚刚开始使用swift在iOS应用程序开发中处理核心数据。我遇到的前两件事是:1.AppDelegate2.NSManagedObjectContext。我知道“AppDelegate.swift”文件是一个源文件,就像“ViewController.swift”一样。但在所有教程中,它都被称为“稍后将使用的东西”。或许,现在是熟悉它的时候了。你能告诉我它到底是做什么的吗?“NSManagedObjectContext”类型的对象有什么作用?它的作用是什么?能不能简单说一下它的作用?提前致谢。 最佳答案 请查看下图以直观地理解iO

ios - Xcode 6 swift multiple segues with prepare for segue

我目前正在开发一个应用程序,其中包含一个主要的ViewController和另外2个ViewControllers。一个是我的浏览器,它工作正常,另一个是TableView。我有5个Buttons引导我到我的浏览器和一个应该去我的TableView。我已将带有PresentModallysegue的Button连接到我的TableViewController(已嵌入NavigationViewController).但是每次我尝试按下按钮时,模拟器都会崩溃并出现此错误:libswiftCore.dylib`swift_dynamicCastClassUnconditional:0x10

swift - iOS 12 错误 : appears to be from a different NSManagedObjectModel than this context's

在iOS12模拟器上启动我的应用程序时,我开始遇到以下错误。有人遇到过这样的问题吗?2018-08-1121:17:44.440144+0300CafeManager[4633:128874][error]error:Thefetchrequest'sentity0x600001f6e940'TablesTable'appearstobefromadifferentNSManagedObjectModelthanthiscontext's我在AppDelegate中定义了全局常量:letviewContext=AppDelegate.viewContext并将其与NSFetchedRe

swift - Swift 闭包中的 "type of expression is ambiguous without more context"错误

我的Swift代码中出现了一个奇怪的类型相关错误:typeofexpressionisambiguouswithoutmorecontext.即使我提供了完整的类型信息,也会发生这种情况。这是重现它的代码。我有两个结构:structPerson{letname_:Stringletaddress_:Address}structAddress{letstreet_:Stringletcity_:String}然后我创建一个包含2个函数的结构来获取和设置Person的address:structLens{letextract:(A)->Bletcreate:(B,A)->A}当我尝试创建一

swift : switch case multiples values from dictionary keys

我想为多个值做一个switchcase,其中这些值是从字典的键中获取的。myDict=["dog":"waf","cat":"meaow","cow":"meuh"]letanimal="cat"switchanimal{casemyDict.keys:print(myDict[animal])case"lion":print("toodangerous!")}default:print("unknownanimal")}如何获取myDict键并将它们转换为元组(或其他))?我尝试了Array(myDict.keys)但它失败了:Expressionpatternoftype'Arra