swift3

Swift 3.0 - Broken func value(for component: Calendar.Component) -> Int?

与世无争的帅哥 提交于 2021-02-07 14:43:10
问题 Is there a workaround for value(for component: Calendar.Component) seemingly being broken? Or a dynamic way to call the property version? func dateComponentsValueShouldBeNil() { let dateComponents = DateComponents(month: 3) debugPrint("Month", dateComponents.month) // "Month" Optional(3) debugPrint("Property", dateComponents.hour) // "Property" nil debugPrint("Enumeration", dateComponents.value(for: .hour)) // "Enumeration" Optional(9223372036854775807) } 回答1: Non-defined date components in a

Swift 3.0 - Broken func value(for component: Calendar.Component) -> Int?

余生颓废 提交于 2021-02-07 14:42:04
问题 Is there a workaround for value(for component: Calendar.Component) seemingly being broken? Or a dynamic way to call the property version? func dateComponentsValueShouldBeNil() { let dateComponents = DateComponents(month: 3) debugPrint("Month", dateComponents.month) // "Month" Optional(3) debugPrint("Property", dateComponents.hour) // "Property" nil debugPrint("Enumeration", dateComponents.value(for: .hour)) // "Enumeration" Optional(9223372036854775807) } 回答1: Non-defined date components in a

Swift 3.0 - Broken func value(for component: Calendar.Component) -> Int?

偶尔善良 提交于 2021-02-07 14:41:47
问题 Is there a workaround for value(for component: Calendar.Component) seemingly being broken? Or a dynamic way to call the property version? func dateComponentsValueShouldBeNil() { let dateComponents = DateComponents(month: 3) debugPrint("Month", dateComponents.month) // "Month" Optional(3) debugPrint("Property", dateComponents.hour) // "Property" nil debugPrint("Enumeration", dateComponents.value(for: .hour)) // "Enumeration" Optional(9223372036854775807) } 回答1: Non-defined date components in a

Passing selected row data to next View Controller Swift 3

≡放荡痞女 提交于 2021-02-07 10:42:26
问题 I am new to Swift Programming and I am having problems. So what I want to do is when the user selects the row in a table then I want to grab the selected row's title and then pass it to the next View Controller. Here is my code for the First View Controller: let senderArray = ["Sogyal","Ram"] let messageArray = ["Hello","What's up?"] cell.senderName.text = senderArray[indexPath.row] cell.senderMessage.text = messageArray[indexPath.row] override func tableView(_ tableView: UITableView,

Open another Mac app

夙愿已清 提交于 2021-02-06 09:01:32
问题 In my app I would like to open another app that is installed on the User's Mac (such as iPhoto). I am not sure what I should be looking for in the documentation. What is this called and how should I do it? Thank you 回答1: Xcode 8.3.2 • Swift 3.1 import Cocoa func openPhotos() { NSWorkspace.shared().open(URL(fileURLWithPath: "/Applications/Photos.app")) } openPhotos() Or using launchApplication with the app name parameter in the method: import Cocoa func openApp(_ named: String) -> Bool {

Could not load IOSurface for time string. Rendering locally instead swift 4

泪湿孤枕 提交于 2021-02-05 20:17:10
问题 Could you help me with this problem when I running my project : Could not load IOSurface for time string. Rendering locally instead I don't know what is going on with my codding ..... pleas help . 回答1: I fixed the problem. Select target -> General -> select Devices with Universal and select Main Interface for iPhone & iPad. 来源: https://stackoverflow.com/questions/52846886/could-not-load-iosurface-for-time-string-rendering-locally-instead-swift-4

Could not load IOSurface for time string. Rendering locally instead swift 4

主宰稳场 提交于 2021-02-05 20:12:12
问题 Could you help me with this problem when I running my project : Could not load IOSurface for time string. Rendering locally instead I don't know what is going on with my codding ..... pleas help . 回答1: I fixed the problem. Select target -> General -> select Devices with Universal and select Main Interface for iPhone & iPad. 来源: https://stackoverflow.com/questions/52846886/could-not-load-iosurface-for-time-string-rendering-locally-instead-swift-4

Initializer for conditional binding must have Optional type, not '[String : Any]'

社会主义新天地 提交于 2021-02-05 10:53:45
问题 Can anyone tell me how to fix this? Im just trying to receive signals from thing speak. `self.title = "Home" print("Requesting data...") Alamofire.request( "https://api.thingspeak.com/channels/290427/feeds.json", parameters: ["results": "1", "location": "false"]) // Gets the latest info from ThingSpeak .responseJSON { response in print("Data downloaded: \(response.result)") if let json = response.result.value as! [String:Any] { print(json) //see full data if let feeds = json["feeds"] as?

Why function return nil FireBase Swift [duplicate]

谁说胖子不能爱 提交于 2021-02-05 09:28:24
问题 This question already has answers here : Unexpected non-void return value in void function Swift3 (2 answers) Closed 2 years ago . Why ever function return nil?! I try add DispathQue but I don't understand how it should be right! Pls Help func storagePutData(uid: String, image: UIImage, compretition: @escaping (Error?) -> Void) -> String { var downloadURL: String! let imageName = NSUUID().uuidString let uploadDara = UIImageJPEGRepresentation(image, 0.1)! let ref = self.refStorage.child(

Sending Data to UIViewController From UIView Subclass With Delegate

回眸只為那壹抹淺笑 提交于 2021-02-05 08:22:27
问题 I have an IBOutlet-connected UIView object (innerView) sitting over view controller ( UIViewController )'s view. I want to let the user rotate innerView with their finger. So I have a subclass (TouchView) of UIView set to innerView's class. As the user rotates the view object, I want the view controller to receive a value from TouchView. And what I have is the following. // UIView protocol TouchDelegate: class { func degreeChanged(degree: Double) } class TouchView: UIView { weak var delegate: