swift2

How to record and play audio simultaneously in iOS using Swift?

醉酒当歌 提交于 2019-12-21 04:00:44
问题 In Objective-C, recording and playing audio simultaneously is fairly simple. And there are tonnes of sample code on the internet. But I want to record and play audio simultaneously using Audio Unit/Core Audio in Swift. There are vary small amount of help and sample code on this using Swift. And i couldn't find any help which could show how to achieve this. I am struggling with the bellow code. let preferredIOBufferDuration = 0.005 let kInputBus = AudioUnitElement(1) let kOutputBus =

How to install Swift package via package manager?

╄→尐↘猪︶ㄣ 提交于 2019-12-21 03:38:21
问题 I am currently following the document from swift.org to play around with the new Swift Package Manager. I cloned the demo project from Github and run the following command from terminal. git clone https://github.com/apple/example-package-dealer.git cd example-package-dealer swift build .build/debug/Dealer While I run swift build , error arise. <unknown>:0: error: no such file or directory: 'build' Any idea? 回答1: I stuck for an hour. Sadly, it's just an epic fail that downloading the wrong

How to conditionally compile version-specific Swift (1.2 vs 2.0) code in the same source file?

青春壹個敷衍的年華 提交于 2019-12-21 02:30:12
问题 I have a Swift demo project that comes bundled with my framework. I want to ensure that the Swift code in the demo compiles successfully with both Xcode 6 (Swift 1.2) and Xcode 7 (Swift 2.0) without user intervention . Since there's only marginal preprocessor support in Swift, how can I determine at compile-time which version of Swift or Xcode is being used to compile the code? Now, here's the important detail: It has to work automatically! Open the project in Xcode 6 -> compiles the Swift 1

Building a Swift Framework with Xcode 7 (Beta 3) to use as an Embedded Binary

半城伤御伤魂 提交于 2019-12-21 00:46:28
问题 Ever since Embedded Binaries were introduced in iOS 8, I have been wanting to port a lot of my common code into frameworks. I decided to wait one year before doing it and this year, with Xcode 7 Beta and iOS 9, I'm starting to do that just that. I have started a Cocoa Touch framework project in Xcode 7 and I want to compile it into a usable framework. I can get it to compile my project into a .framework, but there's a few issues; namely, the framework doesn't appear to be importable into new

How do I filter events created for the current date in the Realm swift?

≯℡__Kan透↙ 提交于 2019-12-20 23:48:12
问题 How do I filter events created for the current date in the Realm swift? I tried something like below but this wrong. let dtSource = datasource.filter("Create == NSDate()").count Update: Getting the filter creating my date as a string. http://i.stack.imgur.com/8fLX9.png http://i.stack.imgur.com/HDR2X.png 回答1: A query in the form of Create == NSDate() will check exact date equality, which will compare down to the second. If you want to check if a date is between a given interval, like checking

Swift 2 - Xcode 7.0 Cannot Access HTTPS site with unstrusted SSL Certificate

风流意气都作罢 提交于 2019-12-20 12:40:06
问题 Experts, I'm a Beginner in IOS 9 / XCODE 7 / Swift 2 Development Kit I'm trying to create an ios app that simply route to Web Application in HTTPS protocol. Below is my code so far in ViewController.swift import UIKit class ViewController: UIViewController { @IBOutlet var myWebView: UIWebView! /** * Function to Display the Web Application initial URL */ func loadAppURL(){ let siteAddress = "https://domain:8443/path/to/page" let url = NSURL (string: siteAddress) let urlRequest = NSURLRequest

Delegate using Container View in Swift

时光怂恿深爱的人放手 提交于 2019-12-20 12:35:50
问题 I'm developing an app for iPad Pro. In this app, containerView use to add additional views and interact with them. First, I created a protocol: protocol DataViewDelegate { func setTouch(touch: Bool) } Then, I created my first view controller import UIKit class ViewController: UIViewController, DataViewDelegate { @IBOutlet var container: UIView! @IBOutlet var labelText: UILabel! override func viewDidLoad() { super.viewDidLoad() } func setTouch(touch: Bool) { if touch == true { labelText.text =

How do I migrate from UIAlertView (deprecated in iOS8)

强颜欢笑 提交于 2019-12-20 11:05:28
问题 I currently have the following line of code in one of my apps. It is a simple UIAlertView . However, as of iOS 8, this is now deprecated: let alertView = UIAlertView(title: "Oops!", message: "This feature isn't available right now", delegate: self, cancelButtonTitle: "OK") How do I update this to work with iOS 8+? I believe I have to change something to UIAlertCotroller , though I'm not too sure what. 回答1: You need to use UIAlertController instead. To class documentation is pretty

Class-Only Protocols in Swift

孤街醉人 提交于 2019-12-20 11:03:30
问题 I want some of my classes (not all) to conform using 'Class-Only Protocols' from docs. What I am doing is protocol RefreshData: class, ClassA, ClassB { func updateController() } and I am getting the errors non class type 'RefreshData cannot inherit from classA non class type 'RefreshData cannot inherit from classB I'm not sure I am following exactly as in the docs. Does anyone have any ideas about this? 回答1: Swift 4 allows you to combine types, so you can have your protocol and then create,

Alamofire not working (Swift/Xcode 8)

烈酒焚心 提交于 2019-12-20 10:32:38
问题 I am getting the following errors when trying to import Alamofire into my project (Cocoapods isn't working for me, so I have to manually import it). Anyway, I'm using XCode 8 and Swift 2.3, and I'm getting these errors: Update: I cleaned XCode, downloaded the latest version of Alamofire and restarted my computer. Now, XCode seems to be giving me conflicting errors (pictures for reference) Thanks! 回答1: As of early September '16, you need to use the following in your Podfile: pod 'Alamofire',