swift3

Retrieving information from the array that mounted the map (MapKit)

≡放荡痞女 提交于 2019-12-12 02:34:19
问题 I have an array with several dictionaries. In every dictionary I have some information. I want to add a point on the map for each item inside the array. I do not have anything but didSelectForAnnotation method, how do I get inside the array as certain information of that object? In a table I would use the indexPath but an annotation does not have that indexPath. Is there a solution?? 回答1: If you want to set custom information with you MKPointAnnotation then you need to subclass it and create

dispatch_group_leave error while adding new child

只谈情不闲聊 提交于 2019-12-12 02:32:26
问题 I am trying to add a new child to my node in firebase using this code: @IBAction func likeButtonOnTouch(_ sender: Any) { if ViewController.usersUid.count > 0 { self.update() } } func update() { let child1: String = (FIRAuth.auth()?.currentUser?.uid)! let ref = FIRDatabase.database().reference().child(child1).child("following") let data1: [String:String] = [ViewController.usersUid[self.currentUser]: "true"] ref.setValue(data1) } But when I press the button, my app crashes with this error:

How to update a UITextField when receiving input from a UIPickerView?

随声附和 提交于 2019-12-12 02:27:53
问题 Currently, I am programmatically creating a UITextField and UIPickerView within cellForRowAt . I can easily update the selected UIPickerView value within didSelectRow if I connect my UITextField to an IBOutlet . However, I require the UITextField to be created programmatically with applied AutoLayout constraints. However, I don't know how to update the UITextField as I have no reference to it in the UIPickerView's didSelectRow function since it's created programmatically within cellForRowAt

How do I decode a Double using NSCoder, NSObject and Swift 3 for iOS

痴心易碎 提交于 2019-12-12 02:25:36
问题 I am trying to store and load an object from persistent storage in Xcode 8.0 using Swift. I have followed the Start Developing iOS Apps (Swift): Jump Right In tutorial from Apple and had the same problem with the integer value for the star-rating. This is a "cropped" version of my class 'Expense' to show the 'amount' variable which I'm having trouble with: class Expense: NSObject, NSCoding { var amount: Double static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in:

How we can add additional UILabels to UINavigation?

青春壹個敷衍的年華 提交于 2019-12-12 02:18:39
问题 I would like to add a cycle view and a label to UINavigation. like this: I can set a label to my UINavigation by this code: if let navigationBar = self.navigationController?.navigationBar { let firstFrame = CGRect(x: 300, y: 0, width: navigationBar.frame.width/2, height: navigationBar.frame.height) let firstLabel = UILabel(frame: firstFrame) firstLabel.text = "First" navigationBar.addSubview(firstLabel) } but I have two problems by this code: 1.how to set x position correctly? (to test I set

Retrieving From Firebase Database with multiple childs

大城市里の小女人 提交于 2019-12-12 02:17:19
问题 I have been working with Firebase for a while with no problem, but Recently I have a database structure with multiple childs, And Im having issues reading it on my code. Here is my Firebase Database Structure: { "news" : { "50OzNLsK" : { "category" : "Anuncio", "content" : [ null, { "paragraph" : { "text" : "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." } }, { "quote" : { "image" : "http://www

Update the first view after dismissing Popover

荒凉一梦 提交于 2019-12-12 02:17:10
问题 I segue from the first view controller(tableview) to the second view controller which is a tableview. After I am dont with the second view, I need to reload table view in the first controller. popoverPresentationControllerDidDismissPopover gets called if I tap outside the popover but what if there is another button in the second tableview which segues back to the first one? Normally I need user to tap Add button to come out of tableview rather than tapping outside the popover. I reserve the

Migrate from swift 2.2 to swift 3.0 in xcode 8

流过昼夜 提交于 2019-12-12 02:16:54
问题 How to migrate from swift 2.2 to swift 3.0 on Xcode 8.0 . Do i need to update all the 3rd party libraries also ? Please help !!! 回答1: Swift 2.2 unfortunately doesn't work with Xcode 8. But Apple made a good move still supporting Swift 2.3, which is basically almost the same as 2.2. The problem is with 3rd party libraries, which must be in the same version of Swift as your project. So, if you're using Swift 2.3, you can't use libraries, that are written in Swift 3.0. 来源: https://stackoverflow

How to parse JSON code to Swift 3 Table View data?

假如想象 提交于 2019-12-12 02:14:47
问题 I am creating an ios application using swift 3 and MySQL and PHP as database. I wanted to output the data from database to a tableview but i kept having an error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." I tried to check the JSON encoding in PHP, and it was ok. Here's my swift code: class Roster: UITableViewController { @IBOutlet weak var rosterbar: UITabBarItem! var class_id = String() var values: Array! =

Swift - Get next date from a array of weekdays

南笙酒味 提交于 2019-12-12 02:14:31
问题 Context I'm making an app where I have tasks with due dates and once they are done I want to set a new due date for according to a new date according to a day of the week repeat pattern chosen by the user. Im saving due dates as Date. Im saving the repeat pattern as Int32 (1 for Sunday, 2 for Monday, 4 for Tuesday...) but I can easily get it to an array of Strings or numbers representing each day Problem How do I get the next due date as Date (so I can repeat the task)? Example if I have a