swift3

EXC_BAD_ACCESS error for invoking method in swift

青春壹個敷衍的年華 提交于 2019-12-25 04:25:01
问题 Here is the code: import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! @IBAction func changeBtn(_ sender: NSButton) { obj1.changeColor() obj2.changeBackgroundColor() objFld1.textColor = obj1.color objFld2.drawsBackground = true objFld2.backgroundColor = obj2.backgroundColor } @IBOutlet weak var objFld1: NSTextField! @IBOutlet weak var objFld2: NSTextField! class colored { var color = NSColor.black var backgroundColor =

Getting Attributes for UI Elements Using AXUIElementCopyAttributeValue Function in Swift3?

点点圈 提交于 2019-12-25 04:15:50
问题 I'm trying to get the title of each ui element inside a window using the following function. func AXUIElementCopyAttributeValue(_ element: AXUIElement, _ attribute: CFString, _ value: UnsafeMutablePointer<CFTypeRef?>) -> AXError However, the function AXUIElementCopyAttributeValue to get AXTitle returns an error. What's the right way to get the values for attributes of UI Elements in swift3? Here's my code. var children:CFTypeRef? var error = AXUIElementCopyAttributeValue((windows?[0])!,

Is it possible to create a class that will imitate a CKRecord?

懵懂的女人 提交于 2019-12-25 04:12:34
问题 So I'm creating an app that will be reusing some records a lot, so I came up with an idea to do that: import CloudKit class Class: CKRecord { override init(recordType: String = "Class") { super.init(recordType: recordType) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } var name: String? { get { return value(forKey: "name") as? String } set { setValue(newValue!, forKey: "name") } } var classDescription: String? { get { return value(forKey:

On cell click display image of particular logged in id

Deadly 提交于 2019-12-25 01:35:15
问题 I need to print image in my next view controller after comparing ID of a table containing user details after comparing the ID I am successfully getting the name but the respective image is unable to fetch if the user has posted anything then I am getting name for particular posted job now what I want is image of from respective user (that image which user uploaded while registration), (which identifies the posted job is posted via which user). Below is my code: func getJOBData() { let jobUrl

getting the height of a label in custom cell to use for heightForRowAt in my main view controller

余生颓废 提交于 2019-12-25 00:53:18
问题 I have a view controller that uses a custom cell called searchCell to bring content in and I am wondering how I can get the height of the label lblLeft and use it in the tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat function to return the height of the label. The code I'm using in my Main View Controller: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if searchMode == searching { let cell: MHSearchCell =

How to identify a local phone contact and an SYNC phone contact in iphone?

本小妞迷上赌 提交于 2019-12-24 20:44:44
问题 I need google id of the contacts, Is there any way to find the google contact id for my address book contact? I found this answer, which shows it is possible in Android. How can I achieve in iOS?? Please help me to find google id from address book. 回答1: How about trying to visit this document. If my understanding is right, you need this Unified Contacts. Contacts in different accounts that represent the same person may be automatically linked together. Linked contacts are displayed in macOS

Replace specific characters in string

随声附和 提交于 2019-12-24 20:40:53
问题 I am currently trying to replace specific characters in a string using Swift 3. var str = "Hello" var replace = str.replacingOccurrences(of: "Hello", with: "_____") print(replace) This will print: _____ but my problem occurs when str changes and consists of a different number of characters or several words such as: var str = "Hello World" Now I want the replace variable to update automatically when str is changed. All characters except 'Space' should be replaced with _ and later print _____ _

how to pass properties to swift 3 urlsession didFinishDownloadingTo delegate after background download?

若如初见. 提交于 2019-12-24 19:37:52
问题 I can successfully download a zip file in background with my app code with ios 10 and swift 3. I use a backgroundsession data task: let backgroundSessionConfiguration = URLSessionConfiguration.background(withIdentifier: (prefix + postfix)) let backgroundSession = Foundation.URLSession(configuration: backgroundSessionConfiguration, delegate: self, delegateQueue: OperationQueue.main) var request = URLRequest(url: dlUrl ) request.httpMethod = "GET" request.cachePolicy = NSMutableURLRequest

How to calculate time difference between current time and yesterday date with static time [duplicate]

萝らか妹 提交于 2019-12-24 19:13:48
问题 This question already has answers here : Getting the difference between two NSDates in (months/days/hours/minutes/seconds) (18 answers) Closed 2 years ago . I have a current time and a static time (eg - yesterday 9.30 pm), I need to find the time difference between these two times in hh:mm:ss format. This is the code I used to get the current time: let date = Date() let calendar = Calendar.current let hour = calendar.component(.hour, from: date) let minutes = calendar.component(.minute, from:

TableView inside tableview cell swift 3

和自甴很熟 提交于 2019-12-24 18:51:17
问题 I'm tring to display tableView inside tableview cell while both parent and child tableview have dynamic cell height. First problem is not all cells show child tableView. In cells that show childTableView, childTableView height is not right. class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var items = ["Consider, though, that Swift uses value types almost exclusively, which is mind-boggling when you consider that the situation in Objective-C is completely the