swift3

Cookies don´t keep user logged in in swift3

蹲街弑〆低调 提交于 2020-01-17 06:52:30
问题 I have this simple application with a UIWebView, but I can not use the cookies to store the loggin or keep the user logged. I open the application, I log in, I close the application, and when I open it again the login fields are blank. I would like at least that the user and password were filled based on cookies this is the code from viewController.swift import UIKit class ViewController: UIViewController { @IBOutlet var myWebView: UIWebView! override func viewDidLoad() { super.viewDidLoad()

iOS Swift How to check Key Availability in NSMutableArray

陌路散爱 提交于 2020-01-17 06:43:52
问题 I am having some set of NSMutableArray like: ( { name = "ILTB"; source = "iltb.net"; }, { name = "Baran Bench"; source = "baranbench.com"; }, { name = "Income Tax India 1"; source = "Income Tax India 1"; } ) How to check Key availability in this NSMutableArray. For Example I need to check "ILTB" is already in my MutableArray or not. 回答1: First of all ILTB is not key but its value for key name . You probably want search from array. Now in Swift instead of NSArray use Swift's native array of

Attempt to present UIAlertController whose view is not in the window hierarchy with localnotification [duplicate]

谁说胖子不能爱 提交于 2020-01-17 05:34:07
问题 This question already has answers here : Attempt to present UIViewController on UIViewController whose view is not in the window hierarchy (30 answers) Closed 2 years ago . I am trying to present AlertView once the user clicks on the local notification. The AlertView has options of cancel or ok. extension ViewController:UNUserNotificationCenterDelegate{ func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler

How to fetch google contacts into an iOS application

你说的曾经没有我的故事 提交于 2020-01-17 03:18:08
问题 I read the below link and now I understood that I need to make an api call to fetch the contacts. As I am new to Swift3 could someone guide me how to do this. I read somewhere that Almofire and Swifty json would help and I also read GData also will help. I am little confused. Please guide me. Google Contacts API 回答1: You might want to try Google Sign-In for iOS, get users into your apps quickly and securely, using a registration system they already use and trust—their Google account. This

sort my TableViewcell with distance comes from response in swift3

荒凉一梦 提交于 2020-01-16 18:34:28
问题 im working on map and tableview. i have 4 locations and i have distance between each other, now i want that when i click on any cell then that cell should comes on 1st position and after with sort all other location will be place. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let indexPath = tableView.indexPathForSelectedRow let currentCell = tableView.cellForRow(at: indexPath!)! print(currentCell.textLabel!.text as Any) print(indexPath?.row as Any) print

Exhaustive catch blocks without empty or wildcard in Swift 3.1

限于喜欢 提交于 2020-01-15 11:54:10
问题 Catch clauses in Swift must be exhaustive. Does it mean I always need to use a wildcard or empty catch clauses whenever I want to avoid error propagation? Example: enum Oops: Error { case oh, ouch, meh } func troublemaker() { do { throw Oops.meh } catch Oops.oh {} catch Oops.ouch {} catch Oops.meh {} // Error: Error is not handled because the enclosing catch is not exhaustive } Of course, it is fixed if I add throws to the function. Same goes for adding either catch {} or catch _ {} . But is

Instantiating classes stored in metatype Dictionary

佐手、 提交于 2020-01-15 10:17:12
问题 I've followed the solution at Make a Swift dictionary where the key is "Type"? to create dictionaries that can use a class type as keys. What I want to do is: I have one dictionary that should store class types with their class type (aka metatype) as keys, too: class MyScenario { static var metatype:Metatype<MyScenario> { return Metatype(self) } } var scenarioClasses:[Metatype<MyScenario>: MyScenario.Type] = [:] Then I have methods to register and execute scenarios: public func

Why do I not see my new UIWindow?

橙三吉。 提交于 2020-01-15 08:55:47
问题 Scenario: Create and display an overlay (ancillary) UIWindow. Related Discussion: How do I toggle between UIWindows? Code: fileprivate func displayOverLay() { let myWindow = {() -> UIWindow in let cWindow = UIWindow(frame: CGRect(x: 10, y: 200, width: 300, height: 300)) cWindow.backgroundColor = UIColor.gray.withAlphaComponent(0.5) cWindow.tag = 100 return cWindow }() myWindow.makeKeyAndVisible() myWindow.windowLevel = UIWindowLevelAlert let storyboard = UIStoryboard(name: "Hamburger", bundle

Stripe API response: the data couldn't be read because it isn't in the correct format

匆匆过客 提交于 2020-01-15 07:50:29
问题 I am making an api call from my iOS app in swift 3 like so: @IBAction func registerAccountButtonWasPressed(sender: UIButton) { let dob = self.dobTextField.text!.components(separatedBy: "/") let URL = "https://splitterstripeservertest.herokuapp.com/account/create" let params = [ "first_name": firstNameTextField.text!, "last_name": lastNameTextField.text!, "line1": addressLine1TextField.text!, "city": cityTextField.text!, "postal_code": postCodeTextField.text!, "country": countryTextField.text!

Error while running Custom Keyboard running on simulator Swift

蹲街弑〆低调 提交于 2020-01-15 05:18:10
问题 I am trying to make custom keyboard.For simple custom keyboard it is running fine, but while clicking on emoji it is showing below error : viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted} I have also tried running this with Device but still it is showing same error. Do anyone know what is the solution for it? 回答1: I encountered same issue like you. it's because of memory leak on simulator. and