swift3

Type Any has no subscript members Error in Swift 3.0?

六眼飞鱼酱① 提交于 2019-12-25 07:18:04
问题 I am following this tutorial here... And the issue I am having is I keep getting the error. "Type Any has no subscript members Error" in this function... func allItems() -> [TodoItem] { let todoDictionary = NSUserDefaults.standardUserDefaults().dictionaryForKey(ITEMS_KEY) ?? [:] let items = Array(todoDictionary.values) return items.map({TodoItem(deadline: $0["deadline"] as! NSDate, title: $0["title"] as! String, UUID: $0["UUID"] as! String!)}).sort({(left: TodoItem, right:TodoItem) -> Bool in

ImageMagick iOS image

寵の児 提交于 2019-12-25 06:07:02
问题 I am trying to preprocess images for OCR(tesseract) on my app, I have found a great script for doing this on Freds ImageMagick Scripts but I don't know how to use Image Magick within an iOS app let alone then run a script to do so. I have googled around and not found much to help so I'm wondering if is possible? I apologise for this being such an open question. Any help would be great. Thanks 来源: https://stackoverflow.com/questions/42763965/imagemagick-ios-image

UITextView scrolling caret to visible text on Device Rotation in Swift 3

99封情书 提交于 2019-12-25 05:20:16
问题 this scrollToCaretInTextView function was working in Swift 2, but on converting to Swift 3, it has an error message that I can't find a solution to. Here is the code: @IBOutlet weak var emailBody: UITextView! override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) { scrollToCaretInTextView(textView: emailBody, animated: true) } func scrollToCaretInTextView(textView:UITextView, animated:Bool) { var rect = emailBody.caretRectForPosition((textView.selectedTextRange?.end)!)

How to use selected value of UIPickerView as time interval for notifications?

◇◆丶佛笑我妖孽 提交于 2019-12-25 05:17:16
问题 I'm trying get a value out of the selected row in UIPickerView and, depending on the selected row, set a time interval for repeating notifications. i.e., users choose "Every 2 minutes" in UIPickerView and get a notification every 120.0 seconds. The second "didSelectRow" method does not seem to store the value in my variable interval , I didn't find a solution for that so far. This is my code so far: import UIKit import UserNotifications import UserNotificationsUI class ViewController:

OAuth2 for MapMyRun using Swift 3

…衆ロ難τιáo~ 提交于 2019-12-25 05:14:20
问题 I'm trying to get user to authenticate my app to work with his data stored on MapMyRun(https://developer.underarmour.com/apps/myapps). Here is my code: let oauth2 = OAuth2CodeGrant(settings: [ "client_id": "asdasdasd", "client_secret": "asdasdasd123", "authorize_uri": "https://www.mapmyfitness.com/v7.1/oauth2/uacf/authorize/?client_id=asdasdasd&response_type=code&redirect_uri=http://localhost.mapmyapi.com:12345/callback", "token_uri": "https://api.mapmyfitness.com/v7.1/oauth2/access_token/",

OAuth2 for MapMyRun using Swift 3

半腔热情 提交于 2019-12-25 05:14:07
问题 I'm trying to get user to authenticate my app to work with his data stored on MapMyRun(https://developer.underarmour.com/apps/myapps). Here is my code: let oauth2 = OAuth2CodeGrant(settings: [ "client_id": "asdasdasd", "client_secret": "asdasdasd123", "authorize_uri": "https://www.mapmyfitness.com/v7.1/oauth2/uacf/authorize/?client_id=asdasdasd&response_type=code&redirect_uri=http://localhost.mapmyapi.com:12345/callback", "token_uri": "https://api.mapmyfitness.com/v7.1/oauth2/access_token/",

Getting Blank Screen in WebView using Swift

北慕城南 提交于 2019-12-25 05:05:00
问题 I am making a simple webview using Swift 3 . But after run am getting only the blank screen. It is not opening the link which I put in url request. import UIKit class ViewController: UIViewController { @IBOutlet var webView: UIWebView! override func viewDidLoad() { super.viewDidLoad() let url = URL (string: "http://www.google.net"); let request = URLRequest(url: url!); webView.loadRequest(request); // Do any additional setup after loading the view, typically from a nib. } override func

AWS Mobilehub: Swift 3 update, shows error at launchoptions

那年仲夏 提交于 2019-12-25 04:57:25
问题 Since I updated my amazon web services app I created with AWS Mobilehub to swift 3 I receive the following error message: As soon as I use "!" to remove the error my app crashes due to a fatal error: 回答1: Sorry, but the AWS Mobile Hub console does not yet provide Swift 3 sample app code. The Swift sample app download can only be used with the legacy compiler setting in the Xcode project. We have received multiple requests for Swift 3 support, so we are working to prioritize it, but I can't

How to change button title from table static cells?

China☆狼群 提交于 2019-12-25 04:57:14
问题 I have HomeViewController that's segued modally to a Navigation Controller with an identifier of: pickSubjectAction And on SubjectPickerTableViewController is where my subjects to choose. This is my code import UIKit class SubjectPickerTableViewController: UITableViewController { var subjects:[String] = [ "English", "Math", "Science", "Geology", "Physics", "History"] var selectedSubject:String? { didSet { if let subject = selectedSubject { selectedSubjectIndex = subjects.index(of: subject)! }

How to ask for remote permission in iOS 10/Swift 3

旧街凉风 提交于 2019-12-25 04:27:39
问题 I want to ask the user for permissions (remote and local notifications, camera and audio) from a separate viewController. The viewcontroller will be presented during the onboarding process, and never again. How can I ask for permissions to display remote notifications outside the AppDelegate? My question is not how to trigger them, but how to make sure that the AppDelegate is "responsible" for handling them once a permission have been granted. Current code in AppDelegate import UIKit import