swift3

How to get the 'n' weekday of a Date

依然范特西╮ 提交于 2020-01-30 11:47:10
问题 I need to translate this function into swift. Basically what does it get the 'n' day of the current week. So for example if i use it with NSDate().getWeekDay(0) it gives me Sun 11 Sept, and so on. But seems rangeOfUnit no longer exists in Swift-3. This was my previous implementation in Swift-2 extension NSDate { func getWeekDay(day: Int) -> NSDate { var beginningOfWeek: NSDate? NSCalendar.currentCalendar().rangeOfUnit(NSCalendarUnit.WeekOfYear, startDate: &beginningOfWeek, interval: nil,

Google Sign In showing blank screen in iOS

有些话、适合烂在心里 提交于 2020-01-30 10:32:47
问题 I have implemented code as per the google SDK documentation line by line in my app, but still when I click on google sign in button app shifts to new view controller with webview with blank screen. Have tried multiple solution found here : GIDSignIn white screen on iOS 91. But no lucks with resolving the problem , have attached the screen shot for getting closer look about the screen. Following are the pods that I'm using, Running XCode 9.1, iOS 10.0 and later. Kindly request someone to help.

Reading/Retrieving Data From Firebase

∥☆過路亽.° 提交于 2020-01-25 22:05:25
问题 I am a beginner to Swift 3 (using iOS 8.3). I have been trying to figure out a way to separate the data but got no luck. Basically, I am able to extract the following data from Firebase: { Database = { Kelvin = { Institution = xxx; "Years of Experience" = "2.5"; location = London; }; Sophia = { Institution = xxxx; "Years of Experience" = 3; location = London; }; }; Users = { SOOlIFsjn3839jcmlBbVEnSRH3 = { email = "testing@gmail.com"; password = 1234567; }; }; } But now I want to separate the

Reading/Retrieving Data From Firebase

天涯浪子 提交于 2020-01-25 22:04:09
问题 I am a beginner to Swift 3 (using iOS 8.3). I have been trying to figure out a way to separate the data but got no luck. Basically, I am able to extract the following data from Firebase: { Database = { Kelvin = { Institution = xxx; "Years of Experience" = "2.5"; location = London; }; Sophia = { Institution = xxxx; "Years of Experience" = 3; location = London; }; }; Users = { SOOlIFsjn3839jcmlBbVEnSRH3 = { email = "testing@gmail.com"; password = 1234567; }; }; } But now I want to separate the

Many leaks showing in Instruments caused by Array and Dictionary

和自甴很熟 提交于 2020-01-25 19:00:27
问题 I was testing my app using Instruments checking for any leaks and to my surprise it's showing many leaks caused mainly by: _ContiguousArrayStorage<String> _ContiguousArrayStorage<Int> _ContiguousArrayStorage<NSLayoutConstraint> _NativeDictionaryStorageOwner<Int, CGFloat> _NativeDictionaryStorageOwner<String, AnyObject> The tests are done on an iPhone 5s, iPhone 6s and iPad Pro. All of the devices are running iOS 10. What can I do about these leaks? 来源: https://stackoverflow.com/questions

Turning Object with SkSpriteNode

╄→гoц情女王★ 提交于 2020-01-24 20:43:11
问题 I have an image named "Ghost" and it moves throughout the screen. I want to have the SpriteNode constantly turning without being pressed on. Ghost = SKSpriteNode(imageNamed: "Ghost1") Ghost.size = CGSize(width: 50, height: 50) Ghost.position = CGPoint(x: self.frame.width / 2 - Ghost.frame.width, y: self.frame.height / 2) Ghost.physicsBody = SKPhysicsBody(circleOfRadius: Ghost.frame.height / 1.4) Ghost.physicsBody?.categoryBitMask = PhysicsCatagory.Ghost Ghost.physicsBody?.collisionBitMask =

Json Parsing in swift 3 using Alamofire

时光怂恿深爱的人放手 提交于 2020-01-24 19:56:05
问题 I am working in swift 3. I am new to ios. I am trying to parse the json data like My jsonVlaue is : { data = ( { Password = "@1234"; UserName = "<null>"; "___class" = OrderTable; "__meta" = "{\"relationRemovalIds\":{},\"selectedProperties\":[\"UserName\",\"created\",\"name\",\"___class\",\"ownerId\",\"updated\",\"objectId\",\"Password\"],\"relatedObjects\":{}}"; created = 1483525854000; name = TestMan; objectId = "4316DEBA-78C1-C7BD-FFBC-3CB77D747F00"; ownerId = "<null>"; updated = "<null>";

Join 2 different labels for text to speech conversion (swift3)

倖福魔咒の 提交于 2020-01-24 19:35:09
问题 Using the speech to text feature I can easily get one label to be spoken. But I want utterance2 to be joined to utterance. I want utterance to be spoken first then when it is finished for utterance2 to be spoken right after. let utterance = AVSpeechUtterance(string: dptext.text!) let utterance2 = AVSpeechUtterance(string: dptext2.text!) let synthesizer = AVSpeechSynthesizer() synthesizer.speak(utterance) 回答1: I think the simplest way to handle this situation is to combine the two string with

How to automatically generate methods like ViewDidLoad

倾然丶 夕夏残阳落幕 提交于 2020-01-24 13:21:31
问题 I want to create a custom class that extends uiviewcontroller with a function that when I create a subClass of my custom class, that function generate automatically. like viewDidLoad and didReceiveMemoryWarning in subclasses of UIViewController. what can I do? My CustomViewController : class CustomViewController: UIViewController My subclass of CustomViewController : class MySubClass: CustomViewController { override func generatedFunction() { //Do something } } 回答1: Use code snippets. Go to

custom titleView of navigationItem is not getting tapped on iOS 11

隐身守侯 提交于 2020-01-24 13:02:31
问题 I am using a custom titleView and assigning it to navigationItem titleView. It had been working fine until iOS 11. Since the update it's position got misplaced to center as originally it was on more left. Beside that user interaction is not working. titleView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?.first as? SomeNib navigationItem.titleView = titleView titleView is just a usual nib. then for enabling interaction: if let titleView = self.navigationItem.titleView { let