swift3

Repeating local notifications for specific days of week (Swift 3 IOS 10)

萝らか妹 提交于 2019-12-17 22:43:16
问题 I am trying to schedule local notifications for specific days of week (e.g. Monday, Wednesday and etc) and then repeat them weekly. This is how the screen for setting notifications looks: User can select time for the notification and repeating days. My method for scheduling single non repeating notification looks like this: static func scheduleNotification(reminder: Reminder) { // Setup notification content. let content = UNMutableNotificationContent() //content.title = NSString

Uploading Image to Firebase Storage and Database

做~自己de王妃 提交于 2019-12-17 22:25:26
问题 I want to put the download URL of images into my Firebase Database. I can upload the Image into storage but I can't figure out how to get the URL into my database with the rest of the "post". @IBOutlet weak var titleText: UITextField! @IBOutlet weak var authorText: UITextField! @IBOutlet weak var mainText: UITextView! @IBOutlet weak var dateText: UITextField! @IBOutlet weak var myImageView: UIImageView! var ref:FIRDatabaseReference? override func viewDidLoad() { super.viewDidLoad() ref =

How to get country code using NSLocale in Swift 3

微笑、不失礼 提交于 2019-12-17 22:22:02
问题 Could you please help on how to get country code using NSLocale in Swift 3 ? This is the previous code I have been using. NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String I can get Language Code as below in Swift 3. Locale.current.languageCode! As I can see, fetching languageCode is straight forward but countryCode property is not available. 回答1: See Wojciech N.'s answer for a simpler solution! Similarly as in NSLocale Swift 3, you have to cast the overlay type Locale

Command Line Tool - Error - xcrun: error: unable to find utility “xcodebuild”, not a developer tool or in PATH

六月ゝ 毕业季﹏ 提交于 2019-12-17 21:41:17
问题 I am getting this error while building the SwiftJSON framework to the Some Xcode project through Carthage Dependency Manager. Sivaramaiahs-Mac-mini:GZipDemoApp vsoftMacmini5$ carthage update --platform iOS *** Fetching GzipSwift *** Fetching SwiftyJSON *** Checking out GzipSwift at "3.1.1" *** Downloading SwiftyJSON.framework binary at "3.1.3" *** xcodebuild output can be found in /var/folders/7m/y0r2mdhn0f16zz1nlt34ypzr0000gn/T/carthage-xcodebuild.apLXCc.log A shell task (/usr/bin/xcrun

cannot subscript a value of type 'inout' [String :Double] (aka inout Dictionary<String, Double>)

点点圈 提交于 2019-12-17 21:36:04
问题 How can if i try to add three menus in the dictionary i wont let me and throws an error when i try to force unwrap the 3rd item in the menu. However if i force unwrap two of them, i can get them sum of two var menu = ["fish": 10.99, "chips": 5.99, "kebab": 6.99] var totalCost = menu["fish"]! + menu["chips"]! + menu["kebab"]! print("The total cost of the three items is \(totalCost)") But when i tried it this way it worked var menu = ["fish": 10.99, "chips": 5.99, "kebab": 6.99] var totalCost =

How to call post service with parameters swift 3.0 Alamofire 4.0?

大憨熊 提交于 2019-12-17 21:25:38
问题 I have parameters in var Param : [String:String] = [:] I am using Alamofire.upload( multipartFormData: { multipartFormData in but in response it says invalid service is their in parameter encoding it goes wrong ? 回答1: multipartFormData is used to upload images on server. So if you want to upload image data then try to use below code. let payload: [String: AnyObject] = [ "key1": "val1" as AnyObject, "key2": true as AnyObject, "key3" : [1,2,3,4] as AnyObject ] let requestString = "http://www

Fibonacci numbers generator in Swift 3

萝らか妹 提交于 2019-12-17 20:40:30
问题 The following Q&A covers a few methods of generating Fibonacci numbers in Swift, but it's quite outdated (Swift 1.2?): Sum of Fibonacci term using Functional Swift Question: How could we generate Fibonacci numbers neatly using modern Swift (Swift >= 3)? Preferably methods avoiding explicit recursion. 回答1: An alternative for Swift 3.0 would be to use the helper function public func sequence<T>(first: T, while condition: @escaping (T)-> Bool, next: @escaping (T) -> T) -> UnfoldSequence<T, T> {

Different cornerRadius for each corner Swift 3 - iOS

这一生的挚爱 提交于 2019-12-17 19:57:58
问题 I want to set different corner radius for a view in Swift -3 , I am able to set the radius for the each corner to the same value like the one mentioned in the following post ,how to set cornerRadius for only top-left and top-right corner of a UIView? Is there a way I can set the corner radius in the following format ? Radius top-left: 18 Radius top-right: 18 Radius bottom-right: 3 Radius bottom-left: 18 回答1: You could set the default layer.cornerRadius to the smallest value and then set the

Swift 3.0 multiple selection with select all cell

℡╲_俬逩灬. 提交于 2019-12-17 19:45:53
问题 I have added data in table view and I have manually added "select all" option to the list at first position, now when the user selects the first option which is 'select all' then the person manually option "Select all" is not selected. Select all, click then work all person or deselect working but signal selection all the person not working "Select all" I have tried the code below but it's not working so can any one help me to solve this? var unchecked:Bool = true func tableView(_ tableView:

UITableView Pagination - Bottom Refresh to Load New Data in Swift

不羁的心 提交于 2019-12-17 19:34:00
问题 I am trying to implement loading data from my backend with pagination. I have seen this, but it loads all the data, all then time. Is this the right way or am I doing something wrong? Thanks in advance. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell print(indexPath.row) if (indexPath.row + 1 < self.TotalRowsWithPages) { cell