[Solved] Why it print out an empty array instead of the array appended with values for the first time in viewDidLoad()?

The call to API.Tag.observeTagPool is asynchronous and it will finish after fetchTagPool() has returned the empty self.tagArr. You need to change fetchTagPool to return the value through a callback function like this: override func viewDidLoad() { super.viewDidLoad() // Note: This will print AA after viewDidLoad finishes // Use trailing closure syntax to pass the trailing … Read more

[Solved] How to fetch contacts NOT named “John” with Swift 3 [closed]

Before I outline how to find those that don’t match a name, let’s recap how one finds those that do. In short, you’d use a predicate: let predicate = CNContact.predicateForContacts(matchingName: searchString) let matches = try store.unifiedContacts(matching: predicate, keysToFetch: [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)]) // use whatever keys you want (Obviously, you’d wrap that in a do–try–catch construct, or … Read more

[Solved] Swift: fatal error: Index out of range

Create two sections One for HomeArr and one for AutoArr. I believe for each section you wanna show a additional cell with some title. So below code should help you. extension ViewController : UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return 2 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { … Read more

[Solved] Do you need a server for SQLite [closed]

Basically it depends on your requirement. If you want to store your data outside of the mobile itself for any reason such as fetching and updating them from multiple devices you can use a server to host your database and perform read, write operations. If not, if you only want to use your data inside … Read more

[Solved] how do i get gender from facebook public profile Facebook IOS Swift SDK

You can get these details using Graph api. Check this link https://developers.facebook.com/docs/graph-api/reference/user let request = FBSDKGraphRequest(graphPath: “\(user-id)”, parameters: [“fields” : “id,name,email,birthday,gender,hometown” ], httpMethod: “GET”) request?.start(completionHandler: { (connection, result, error) in // Handle the result }) solved how do i get gender from facebook public profile Facebook IOS Swift SDK

[Solved] How to connect a seconds timer to a minutes timer in Swift? [closed]

I would not use separate timers. Have a seconds timer that fires once a second. It sounds like you want a count-down timer. So… Record the time when the timer starts using code like this: let secondsToEnd = 60*5 let startInterval = NSDate.timeIntervalSinceReferenceDate() let endInterval = startInterval + Double(secondsToEnd) Then in your timer code: let … Read more

[Solved] How can I set the day of the week as a variable in Swift? [closed]

Assuming you need the name of the current weekday in the current locale: let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale.currentLocale() let today = NSDate() let calendar = NSCalendar.currentCalendar() let todayComponents = calendar.components(.CalendarUnitWeekday, fromDate: today) let weekDayIdx = todayComponents.weekday let weekday = dateFormatter.weekdaySymbols[weekDayIdx] as! String println(weekday) // “Wednesday” solved How can I set the day of … Read more

[Solved] How to convert String and perform calculation in Swift? [closed]

I advise you to read the Apple docs at developer.apple.com “I have 67+89.06 Dollars.” // In order to get a Float value both operands need to be of type Float. let valueCalculate = “I have \(Float(67) + Float((89.06))) Dollars” print(valueCalculate) // Convert String to Int var stringNumber = “123456” var convertToInt = Int(stringNumber) // Convert … Read more

[Solved] Swift – how to make window unactivable?

Actually all you need is .nonactivatingPanel style panel. Everything else is details, like level of this window, custom views with overridden acceptsFirstMouse:, needsPanelToBecomeKey, etc. Btw, button accepts first click by default, non activating app in this case. So your AppDelegate, for example, might look like the following: class AppDelegate: NSObject, NSApplicationDelegate { var docky: NSPanel! … Read more

[Solved] How to return an subset of Array of characters?

You need to map the Character array back to String let resultsArray = lettersarray.dropLast(lettersarray.count – targetNum).map{String($0)} alternatively (credits to Leo Dabus) let letters = “abcdefghijklmnopqrstuvwxyz” let targetNum = 14 let resultsArray = letters.characters.prefix(targetNum).map{String($0)} 4 solved How to return an subset of Array of characters?

[Solved] Value of type ‘(UIButton) -> ()’ has no member ‘setImage’

Your @IBAction function has the same name as the button, this causes a name ambiguity. Change the name of the function to something else. @IBAction func houseLockPressed(_ sender: UIButton) Also, you are missing the button’s name in the third line. Change self to self.houseLock to refer to the button. 9 solved Value of type ‘(UIButton) … Read more

[Solved] How to display data in table view in swift 3?

For starters, update the following datasource methods func numberOfSections(in tableView: UITableView) -> Int { return finalDict.count } func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { let titles = Array(finalDict.keys) return titles[section] } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { let titles = Array(finalDict.keys) let currentTitle = titles[section] let values = … Read more