swift3

Convert URLRequest to NSMutableURLRequest

落爺英雄遲暮 提交于 2019-12-23 08:48:21
问题 I'm trying to convert a URLRequest to a NSMutableURLRequest in Swift 3.0 but I can't get it to work. This is the code I have: var request = self.request URLProtocol.setProperty(true, forKey: "", in: request) But it says cannot convert type URLRequest to type NSMutableURLRequest. When I try to cast using 'as' it just says the cast will always fail. What do I do? 回答1: The basics of this are get a mutable copy, update the mutable copy then update request with the mutable copy. let mutableRequest

UI Tests - isSelected is always returning false

喜你入骨 提交于 2019-12-23 08:32:10
问题 We have updated out Swift 2.3 project to Swift 3 recently using Xcode 8.2.1 (8C1002), and now most of our UI Tests related with tableViews and the isSelected property aren't working. It's always returning false, even when the object is selected (we can see it in the iOS Simulator). Has anyone experienced similar issues? Our code used to work normally in Swift 2.3 before the conversion. Here is how we retrieve a tableView cell: let cell = app.tables.cells.element(at: 4) Note: app is a

UI Tests - isSelected is always returning false

。_饼干妹妹 提交于 2019-12-23 08:32:05
问题 We have updated out Swift 2.3 project to Swift 3 recently using Xcode 8.2.1 (8C1002), and now most of our UI Tests related with tableViews and the isSelected property aren't working. It's always returning false, even when the object is selected (we can see it in the iOS Simulator). Has anyone experienced similar issues? Our code used to work normally in Swift 2.3 before the conversion. Here is how we retrieve a tableView cell: let cell = app.tables.cells.element(at: 4) Note: app is a

(Swift 3) Trying to sort an array of class objects by Date in swift 3?

ⅰ亾dé卋堺 提交于 2019-12-23 07:40:57
问题 I have an array of objects that has a member that is type Date , and I'm trying to sort the whole array by Date , and it's not sorting correctly. This is the code I'm using, the name of the array is alarms and the name of the member type Date is time . alarms.sort(by: { $0.time.compare($1.time) == .orderedAscending }) and whenever I sort it it just doesn't work correctly, and I'm testing it by printing all the values in a for loop. Can someone help me with the syntax for this? 回答1: The

Date._unconditionallyBridgeFromObjectiveC(NSDate?) crash in Swift 3

旧城冷巷雨未停 提交于 2019-12-23 07:38:58
问题 I have following function in a swift file. I am calling this from Obj C file with NSDate in place of startDate. And quite often, not every time, my app crashes with Date._unconditionallyBridgeFromObjectiveC(NSDate?) How can I fix this? func trackMeetingEnded(_ name: String, startDate: Date, backgroundTime: TimeInterval) {} Stack trace Crashed: com.apple.main-thread 0 libswiftFoundation.dylib 0x102061e98 static Date._unconditionallyBridgeFromObjectiveC(NSDate?) -> Date + 72 1 Acid 0x10017ece4

Conforming to Hashable protocol?

…衆ロ難τιáo~ 提交于 2019-12-23 07:21:54
问题 I'm trying to make a dictionary with the key as a struct I've created and the value as an array of Ints. However, I keep getting the error: Type 'DateStruct' does not conform to protocol 'Hashable' I'm pretty sure I've implemented the necessary methods but for some reason it still doesn't work. Here's my struct with the implemented protocols: struct DateStruct { var year: Int var month: Int var day: Int var hashValue: Int { return (year+month+day).hashValue } static func == (lhs: DateStruct,

Action Button Not Appearing in Notification iOS 10

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:04:11
问题 I am using local push notifications in my app. when added action button for the notification in iOS 10, it doesn't appear below the notification. the notification is appearing, but the action button is missing at the bottom of the notification. The appdelegate code is given below. import UIKit import CoreData import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication,

Swift 3 ambigous use of 'row'

烈酒焚心 提交于 2019-12-23 07:02:31
问题 I just migrated to swift 3 and i am getting this error ambiguous use of row on indexPath same on section and item . Other properties are just working like count . Most probably it is because of inferring. Here is the ambiguity: Here is the full log screenshot: I am using AlecrimCoreData third party and it has the following extension: // MARK: - IndexPath extensions extension IndexPath { public init(forRow row: Int, inSection section: Int) { self.init(indexes: [section, row]) } //public var

Swift 3 ambigous use of 'row'

狂风中的少年 提交于 2019-12-23 07:02:03
问题 I just migrated to swift 3 and i am getting this error ambiguous use of row on indexPath same on section and item . Other properties are just working like count . Most probably it is because of inferring. Here is the ambiguity: Here is the full log screenshot: I am using AlecrimCoreData third party and it has the following extension: // MARK: - IndexPath extensions extension IndexPath { public init(forRow row: Int, inSection section: Int) { self.init(indexes: [section, row]) } //public var

why is string response from server changing when I am using alamofire in ios app?

≯℡__Kan透↙ 提交于 2019-12-23 06:58:25
问题 I am trying to retrieve a string from server using alamofire in an ios app but the problem is that the response is changing as it is prefixing ever entity with "\" character. here is my code: func getInformation() { self.activityIndicator.startAnimating() let parameters: Parameters = ["SchoolCode": "TCenYrhWUQH7kKLVZ1FQgQ==", "FacultyInfoCode":"cFl9ivLKKKk5PgH4tbi/Gg=="] Alamofire.request("http://epunjabschool.gov.in/webservice/staffwebservice.asmx/StaffDetails", method: .post, parameters: