swift4.2

ReplayKit stops screen recording in background mode of the application or outside the app?

旧时模样 提交于 2019-12-12 09:51:34
问题 I've implemented screen recording with ReplayKit in foreground mode of the application. But when I'm going outside the app with home button app stops background record. --> There is an app available In App Store which allows background screen record. --> If I have to use Broadcast upload and UI extension then please provide me some programming guide. I've added both in my app but still it stops recording in background mode. Below is my code import UIKit import ReplayKit class ViewController:

Using RealmSwift to save an one-to-many relationship object

橙三吉。 提交于 2019-12-11 19:28:15
问题 I'm coming from a Ruby on Rails-like data structure in terms of relationships. So in Rails: Foo has many Bars and Bar has one Foo. Going through the RealmSwift docs, I came up with this, I think: class Foo: Object { // other props var bars = List<Bar>() // I hope this is correct } class Bar: Object { // other props @objc dynamic var foo: Foo? } If the above is corrct, I struggle to know how to create this relationship object. // I need to create Foo before any Bar/s var foo = Foo() foo

How can we pass the closures to any ViewController in the app flow?

心不动则不痛 提交于 2019-12-11 18:42:20
问题 In View Controller A, var completionBlock: (((String) -> ()))? = nil & I am calling the completion block like(ViewController A): if let block = completionBlock { block("block data to pass") } I don't want to pass the completion data to ViewController B, instead i want to pass to ViewController C which is presenting from ViewController B. In simple words, i want to pass the closure data to from ViewController A to ViewController C.I know how to pass data with delegates, just curious with

Can't encode an Audio file to Base64?

血红的双手。 提交于 2019-12-11 10:55:22
问题 Objective: Dialog Flow Voice Bot Api I need to send a wav file to the Dialog Flow Api and the format and settings were pre-defined. So I recorded an audio using AVAudioRecorder in .wav format using following settings audioFilename = getDocumentsDirectory().appendingPathComponent("input.wav") let settings: [String: Any] = [ AVFormatIDKey: Int(kAudioFormatLinearPCM), AVSampleRateKey: 16000, AVNumberOfChannelsKey: 2, AVLinearPCMBitDepthKey: 16, AVLinearPCMIsBigEndianKey: false,

reload tableView from Another ViewController Swift 4.2

眉间皱痕 提交于 2019-12-11 09:55:40
问题 when i am trying to call method from another VC reloadData() then the app crash Fatal error: Unexpectedly found nil while unwrapping an Optional value due to tablview nil how can resolve it. FavoritesFiltersViewController.shareInstance.reloadData() 回答1: You can use notificationCenter for the reload tableView data from another viewController like below : 1. You can add this line to another viewController. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "newDataNotif"),

How to get data from popup view controller to custom table view cell?

大憨熊 提交于 2019-12-11 07:54:55
问题 I have 3 view controllers. First is MainViewController . In this MainViewController has custom table view cell as FoodCell class with two property as name and price . I instantiate this objects in MainViewController and when tap to table view cell this objects pass to popup DetailViewController which is not table view it is only View with labels(foodName and foodPrice labels) and AddToBasket button. And finally I want to pass this class objects from popup DetailViewController to

Binding a button (UIView) to keyboard that works in multiple textfields (Swift 4.2)

心不动则不痛 提交于 2019-12-11 04:37:19
问题 Sorry if any similar question(s) has been answered. But, I just can't seem to figure this one out. I have reached my goal, to bind the "Log In" button to the keyboard, basically pushing it from the bottom of the screen to the top of the keyboard using an extension below. picture: Initial view without keyboard. picture: keyboard has been launched. My UIView extension: import UIKit extension UIView{ func bindToKeyboard(){ NotificationCenter.default.addObserver(self, selector: #selector

Avoid Equatable and Hashable boilerplate, Swift 4.2

 ̄綄美尐妖づ 提交于 2019-12-11 04:25:33
问题 On project we are using classes for model's layer and because of that I have to write code like this: // MARK: - Hashable extension Player: Hashable { static func == (lhs: Player, rhs: Player) -> Bool { return lhs.hashValue == rhs.hashValue } func hash(into hasher: inout Hasher) { hasher.combine(self.name) } } Can this boilerplate can be somehow avoided? Is it possible to implement that Equatable compare by .hashValue by default? Thanks. 回答1: You could write your custom template via Stencil

Facing Issue with CGAffineTransform in NIB

梦想的初衷 提交于 2019-12-11 02:20:00
问题 I have 2 Views ( viewLeft , viewRight ). I am rotating these views with angel 0 (initial setup) by calculating the same anchor point so that it looks like views are rotating across hinge. I have done below code, which is working fine if I took the views in storyboard (viewcontroller) and it does not work if I copy and paste same views and code in nib. In Nib, at 0 angel views leaves some space between them. It is weird behavior, I checked all code outlets and constraints, everything is fine

How to Open a Notification view controller when a iOS push notification is received?

99封情书 提交于 2019-12-10 11:37:40
问题 I am working in swift 4.2 , and Push notification receive from FireBase . When I tap the Notification , it go to Homepage. But I want to go to Notification page. This is Swift4.2 , Xcode 9.3 , iOS 12.1 . In the past , I have tried but not working both Foreground and InActive the app func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() UINavigationBar.appearance().barTintColor =