swift3

In Swift,there's no way to get the returned function's argument names?

穿精又带淫゛_ 提交于 2019-12-18 09:21:17
问题 When a function's return value is another function,there's no way to get the returned function's argument names.Is this a pitfall of swift language? For example: func makeTownGrand(budget:Int,condition: (Int)->Bool) -> ((Int,Int)->Int)? { guard condition(budget) else { return nil; } func buildRoads(lightsToAdd: Int, toLights: Int) -> Int { return toLights+lightsToAdd } return buildRoads } func evaluateBudget(budget:Int) -> Bool { return budget > 10000 } var stopLights = 0 if let townPlan =

Disclosure indicator to specific cell in static TableView in Swift

守給你的承諾、 提交于 2019-12-18 09:09:16
问题 I created a static TableView and I would like to add or remove a disclosure indicator depending if we are consulting our own account or a guest account. This is what I would like : let index = IndexPath(row: 4, section: 0) let cell = tableView.cellForRow(at: index) if currentUser { cell.accessoryType = .none //cell.backgroundColor = UIColor.red } I tried to put it in the viewDidLoad function but it didn't work. I tried cellForRowAt indexPath also and same result. How could I do that? 回答1:

Swift closure in array becomes nil in Objective-c

北城以北 提交于 2019-12-18 09:04:37
问题 I created an objective-c method which will invoke a method via NSInvocation: typedef void (^ScriptingEmptyBlock)(); typedef void (^ScriptingErrorBlock)(NSError *error); - (void)scripting_execute:(NSString *)operation withParams:(nullable NSArray *)args { SEL selector = [self scripting_selectorForOperation:operation]; Class class = [self class]; NSMethodSignature *signature = [class instanceMethodSignatureForSelector:selector]; NSInvocation *invocation = [NSInvocation

Swift 3.0 - how to hide status bar after calling UIImagePickerController?

霸气de小男生 提交于 2019-12-18 08:54:05
问题 Happy New Year! I want to hide status bar after calling UIImagePickerController on iOS 10.2. You know there are already several questions about it with some answers, but I'm afraid the answers don't work for Swift 3.0. The suggested answers are: extend UINavigationController to override preferStatusBarHidden, because UIImagePickerController is a subclass of UINavigationController. So I tried: extension UINavigationController{ open override var prefersStatusBarHidden: Bool{ return true } }

Swift 2 to 3 Migration dispatch_get_global_queue [duplicate]

五迷三道 提交于 2019-12-18 07:23:56
问题 This question already has answers here : How do I dispatch_sync, dispatch_async, dispatch_after, etc in Swift 3, Swift 4, and beyond? (6 answers) Closed 3 years ago . I have the following code that I've been trying to translate into swift 3 from swift 2. Here is what I have so far. DispatchQueue.async(group: DispatchQueue.global(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),execute: { self.controllerDelegate?.codeToRun(progressWindowViewController: self) }) I am getting an error that says Cannot invoke

How do I change the size of a 2x2 UICollectionView and fit the whole screen: Swift 3 Xcode 8

徘徊边缘 提交于 2019-12-18 07:15:31
问题 Hi I am creating an app which requires a grid of images. As an example I am using a 2x2 grid of images in cells of a UICollectionView. I would like to know how I could decrease the annoying space in the middle and also make them have equal widths and heights to fit the whole screen. I know that I can do this with Interface builder. However, I want to do this programmatically because as the app progresses, there will be different levels and different number of squares - possibly a 10x10 also.

unexpectedly found nil while unwrapping an Optional value keyboardWillShow

一曲冷凌霜 提交于 2019-12-18 07:10:20
问题 I have this code below which runs when the keyboardWillShowNotification is called: func keyboardWillShow(_ notification: Notification) { //ERROR IN THE LINE BELOW keyboard = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as AnyObject).cgRectValue animaton = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as AnyObject).doubleValue UIView.animate(withDuration: 0.4, animations: { () -> Void in self.scrollView.frame.size.height = self.scrollViewHeight - self.keyboard

UISwipeGesture 'unrecognized selector sent to instance'

拟墨画扇 提交于 2019-12-18 07:07:04
问题 If someone could please help me resolve this issue, would be great! I have spent a few hours trying to fix, with no luck Error... 2016-06-23 20:30:43.341057 Scaling Rings[408:38903] [DYMTLInitPlatform] platform initialization successful 2016-06-23 20:30:43.750822 Scaling Rings[408:38776] Metal GPU Frame Capture Enabled 2016-06-23 20:30:43.751531 Scaling Rings[408:38776] Metal API Validation Enabled 2016-06-23 20:30:48.293661 Scaling Rings[408:38776] -[Scaling_Rings.MenuScene slide:]:

Firebase Invalid registration token. Check the token format

落爺英雄遲暮 提交于 2019-12-18 06:57:32
问题 This questions has been asked and answered many times before, yet I can't figure out what I am doing wrong. Sending notifications to the whole app from Firebase console works, but if I send to a single token, I get error in firebase console: "Firebase Invalid registration token. Check the token format" I am testing the app on an Iphone device. created new key at https://developer.apple.com/account/ios/authkey/ downloaded the p8 file got the Team ID from https://developer.apple.com/account/#

How to use Google Analytics for iOS via cocoapods

点点圈 提交于 2019-12-18 06:12:52
问题 In my bridging header, I infinitely get "<Google/Analytics.h> not found" I followed Google's own tutorial: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift I've tried the 'pod GoogleAnalytics' methods people have posted. I've tried all of the suggestions people have posted in other threads. Is there something else I need to change in the "build settings" ... or does 'pod install' do everything? Bridging Header: Build Settings: Podfile: 回答1: Swift 4.0 and xcode 9