swift2

Import Objective-C Framework (CocoaPod) into Swift?

你。 提交于 2019-12-21 09:13:39
问题 I'm trying to import the libjingle_peerconnection framework into my Xcode project, but for some reason I can't import the Objective-C header with import RTCICEServer in Swift source files. I have attempted to use header files, etc. What am I doing wrong? # Uncomment this line to define a global platform for your project # platform :ios, '8.0' # Uncomment this line if you're using Swift use_frameworks! target 'VideoRTCTest' do pod "libjingle_peerconnection" end target 'VideoRTCTestTests' do

Import Objective-C Framework (CocoaPod) into Swift?

﹥>﹥吖頭↗ 提交于 2019-12-21 09:13:04
问题 I'm trying to import the libjingle_peerconnection framework into my Xcode project, but for some reason I can't import the Objective-C header with import RTCICEServer in Swift source files. I have attempted to use header files, etc. What am I doing wrong? # Uncomment this line to define a global platform for your project # platform :ios, '8.0' # Uncomment this line if you're using Swift use_frameworks! target 'VideoRTCTest' do pod "libjingle_peerconnection" end target 'VideoRTCTestTests' do

How to reference non-supported frameworks in Watch OS 2

情到浓时终转凉″ 提交于 2019-12-21 07:55:27
问题 I updated my app to the latest swift 2.0 syntax. In doing so, My watchkit app has become broken. The issue is the watchkit app references a class that references the framework AVFoundation. WatchOS2 apparently now no longer supports some of the standard frameworks: Support for network-based operations includes the following technologies: WatchKit extensions can access the network directly through an NSURLSession object. WatchKit extensions have full access to the NSURLSession capabilities,

Subscript of a struct doesn't set values when created as an implicitly unwrapped optional

孤人 提交于 2019-12-21 06:19:30
问题 Why can't I change the the "numbers" array using subscripts when "Foo" is an implicitly unwrapped optional? struct Foo { var numbers = [0,0,0] subscript(index: Int) -> Int { get { return self.numbers[index] } set { self.numbers[index] = newValue } } } var fooA:Foo! fooA = Foo() fooA[1] = 1 // does not change numbers array fooA[1] // returns 0 fooA.numbers[1] = 1 // this works fooA[1] // returns 1 var fooB:Foo! fooB = Foo() fooB![1] = 1 // this works fooB![1] // returns 1 For some reason it

Decrypt Media Files in chunks and play via AVPlayer

筅森魡賤 提交于 2019-12-21 05:32:16
问题 I have a mp4 video file which i am encrypting to save and decrypting to play via AVPlayer. Using CRYPTOSWIFT Library for encrypting/decrypting Its working fine when i am decrypting whole file at once but my file is quite big and taking 100% CPU usage and lot of memory. So, I need to decrypt encrypted file in chunks. I tried to decrypt file in chunks but its not playing video as AVPlayer is not recognizing decrypted chunk data maybe data is not stored sequentially while encrypting file. I have

Swift 2: UITableViewDataSource protocol extension

a 夏天 提交于 2019-12-21 05:26:14
问题 I have been playing around with protocol extensions and I have a problem. Maybe what I want to achieve can’t be done. I have this playground: //: Playground - noun: a place where people can play import UIKit protocol ArrayContainer { typealias T var array: [T] { get } } class MyViewController: UIViewController, ArrayContainer, UITableViewDataSource { typealias T = String var array = ["I am", "an Array"] } extension UITableViewDataSource where Self: ArrayContainer { func

Swift: static property in protocol extension CAN be overridden, but why?

家住魔仙堡 提交于 2019-12-21 05:04:18
问题 I watched "Protocol-Oriented Programming in Swift" and read the related docs, but I still think there is a conflict in the following sample code (try it in a Playground). protocol X { // The important part is "static" keyword static var x: String { get } } extension X { // Here "static" again static var x: String { get { return "xxx" } } } // Now I'm going to use the protocol in a class, BUT // in classes "static" is like "final class", // i.e. CAN'T BE OVERRIDDEN, right? // But I'd prefer to

iOS9: Using dynamic framework with Simulator and Device

孤人 提交于 2019-12-21 04:34:12
问题 I created a dynamic cocoa framework that I would like to use across my apps. After I build the framework for an actual device, I bring it over to an app. I can only run the app on that device. When I try to run it on a simulator, framework files are not recognized. I get error messages: 'ViewController' is unavailable: cannot find swift for declaration for this class I tried building the framework for an iPhone 6 simulator and running the app on an iPhone 6 simulator, but the same problem

how to use socket in swift (connect, send and get message)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 04:25:17
问题 I am new swift. I want to make chat for iphone so i need to use client sokect. how to make this. give me advise or example plz. I tried this https://github.com/socketio/socket.io-client-swift but not connected and tried this code let client:TCPClient = TCPClient(addr: "89.236.254.27", port: 9000) let (success,errmsg) = client.connect(timeout: 1) if success { let (success,errmsg) = client.send(str:"Hello World!") if success { let data = client.read(1024 * 10) if let d = data { if let str =

Swift - 'sharedApplication is unavailable.' Use view controller based solutions where appropriate instead

和自甴很熟 提交于 2019-12-21 04:22:19
问题 I am opening an external URL in my Swift app using the line: UIApplication.sharedApplication().openURL(url) This was working fine until I added Realm to my project via CocoaPods. At that point, it started giving me the two compile errors below: 'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead. 'openURL' is unavailable These errors indicate that the API is unavailable to Application Extensions, but my code is in a normal application, not an