swift3

No such module 'FirebaseDatabase'

会有一股神秘感。 提交于 2019-12-22 05:09:19
问题 I am developing iOS app with Swift 3 with Firebase database. My Podfile: target 'MyApp' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for MyApp pod 'Firebase/Core' pod 'Firebase/Auth' pod 'Firebase/Database' end I run pod install , which installs the pods. I created a class: import Foundation import FirebaseDatabase // Error: no such module 'FirebaseDatabase' class MyDatabase { var ref: DatabaseReference! ... } But I get

No '+=' candidates produce the expected contextual result type 'Int' [duplicate]

南笙酒味 提交于 2019-12-22 04:45:14
问题 This question already has answers here : How to rewrite Swift ++ operator in ?: ternary operator (2 answers) Closed 3 years ago . I've been updating my Swift code for Swift 3 (really excited) and so far so good. But I did tumble accros one little bit of code I can't seem to update. I KNOW I am missing something very simple, but I just can't see what. Here is what I have in Swift 2.2: var column = 0 [...] for item in 0 ..< collectionView!.numberOfItemsInSection(0) { [...] column = column >=

dispatchqueue in swift 3 appears as unresolved identifier [duplicate]

£可爱£侵袭症+ 提交于 2019-12-22 04:42:56
问题 This question already has answers here : Swift 3.0 unresolved identifier for DispatchQueue (2 answers) Closed 3 years ago . I am trying to take/record video asynchronously on the main thread. However, when I call dispatch.main.async , I always get the error: use of unresolved identifier DispatchQueue I've looked everywhere from WWDC to Apple's Documentation, but I see no evidence of the type being deprecated. Here is the code: if !self.cameraEngine.isRecording { if let url =

Creating Launch Screen.xib for iOS8 ( … iOS11, Swift 4 and LaunchScreen.storyboard )

倾然丶 夕夏残阳落幕 提交于 2019-12-22 04:19:48
问题 I've just found out that in order to be able to have the description for your app in the app store say "This app is optimized for iPhone 6, and iPhone 6 Plus." you need to use a launch XIB or storyboard file for your launch images (per [Apple][1]). So, I've created a new Launch Screen xib and now I'm a little but since I usually do everything in code and don't use interface builder. I've deleted the default label that is inserted and dropped a UIImageView into the view. Now I'm wondering how

How to select CollectionView cell in RxSwift

怎甘沉沦 提交于 2019-12-22 04:13:07
问题 I need to select the item at specific index in collection view using RxSwift.This method is not working fine. collectionView.rx.modelSelected(SearchResult.self).subscribe(onNext:{ menuItem in }).addDisposableTo(disposeBag) Can anybody help? 回答1: If you want the indexPath of item selected you can use the following : collectionView .rx .itemSelected .subscribe(onNext:{ indexPath in //your code }).disposed(by: disposeBag) and if you want to the model being selected : collectionView .rx

What is the equivalent of a Java HashMap<String,Integer> in Swift

梦想的初衷 提交于 2019-12-22 02:31:20
问题 I have an example written in Java that I would like to convert into Swift. Below is a section of the code. I would really appreciate if you can help. Map<String, Integer> someProtocol = new HashMap<>(); someProtocol.put("one", Integer.valueOf(1)); someProtocol.put("two", Integer.valueOf(2)); for (Map.Entry<String, Integer> e : someProtocol.entrySet() { int index = e.getValue(); ... } NOTE: entrySet() is a method of the java.util.Map interface whereas getValue() is a method of the java.util

How to set the shared URLCache in swift 3?

天大地大妈咪最大 提交于 2019-12-22 01:39:08
问题 This is the code we had in Swift 2. What is the Swift 3 version? I don't see a replacement for setShared. let sharedCache: NSURLCache = NSURLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil) NSURLCache.setSharedURLCache(sharedCache) 回答1: This works in Xcode 8 Beta 4 URLCache.shared = sharedCache 回答2: Here is an Example in Swift 3 increasing cache size to 500 MB let memoryCapacity = 500 * 1024 * 1024 let diskCapacity = 500 * 1024 * 1024 let cache = URLCache(memoryCapacity:

How would I store a video into firebase storage from swift?

大憨熊 提交于 2019-12-22 01:09:49
问题 I'm trying to select a video from a users camera roll which I have done now I"m not sure how to save it to the firebase storage system, how would I got about doing that? 回答1: 1) Create a reference to your storage 2) Upload your file. (It can be video or audio or images) import FirebaseStorage var storage = FIRStorage.storage() var storageRef = storage.reference(forURL: "gs://xyz.appspot.com") let uploadTask = storageRef.putFile(from: localFile, metadata: nil) { metadata, error in if let error

Generic IBDesginables UIView extension

与世无争的帅哥 提交于 2019-12-22 00:36:32
问题 I would like to create generic extension for class to add some designables functionality to any UIView subclass and by this avoid adding functionality to all subclasses. So, would be nice to add extension for UIView which conforms to protocol SomeProtocol (It's empty because it is just a tag to mark classes which I want functionality to be added). Then just add that protocol in any UIView subclass where I want that functionality to be implemented like this: protocol SomeProtocol { //empty }

Fill UIImage with UIColor

非 Y 不嫁゛ 提交于 2019-12-22 00:12:48
问题 I have a UIImage that I want to fill with UIColor I've tried this code but the app crashes on the 10th row. Here's the code: extension UIImage { func imageWithColor(_ color: UIColor) -> UIImage { UIGraphicsBeginImageContextWithOptions(size, false, scale) let context = UIGraphicsGetCurrentContext() context?.translateBy(x: 0.0, y: size.height) context?.scaleBy(x: 1.0, y: -1.0) context?.setBlendMode(CGBlendMode.normal) let rect = CGRect(origin: CGPoint.zero, size: size) context?.clip(to: rect,