swift3

“classname has no member functionname” when adding UIButton target

孤者浪人 提交于 2019-12-17 07:36:30
问题 Super newb in Swift and iOS development here. I am following this tutorial about implementing a custom control in a single view iOS app. It's a Swift 2 tutorial, but so far I'm doing OK transposing everything to 3 as I go (I use XCode 8 Beta). I have a custom class, RatingControl , connected to a View in the storyboard. In the class's constructor, I create a button: let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44)) button.backgroundColor = UIColor.red() Then, I try to

Can't Hide Status Bar—Swift 3, [duplicate]

假装没事ソ 提交于 2019-12-17 07:26:13
问题 This question already has an answer here : The supportedInterfaceOrientations method doesn't override any method from its superclass (1 answer) Closed 3 years ago . I usually hide the status bar with override func prefersStatusBarHidden() -> Bool { return true } but Xcode is giving me an error, saying "Method does not override anything from its superclass". If I delete the override , Xcode gives a different error: "Method 'prefersStatusBarHidden()' with Objective-C selector

Can't Hide Status Bar—Swift 3, [duplicate]

我与影子孤独终老i 提交于 2019-12-17 07:26:06
问题 This question already has an answer here : The supportedInterfaceOrientations method doesn't override any method from its superclass (1 answer) Closed 3 years ago . I usually hide the status bar with override func prefersStatusBarHidden() -> Bool { return true } but Xcode is giving me an error, saying "Method does not override anything from its superclass". If I delete the override , Xcode gives a different error: "Method 'prefersStatusBarHidden()' with Objective-C selector

Swift 3 Core Data Delete Object

半世苍凉 提交于 2019-12-17 07:17:50
问题 Unfortunately the new Core Data semantics make me crazy. My previous question had a clean code that didn't work because of incorrect auto generation of header files. Now I continue my work with deleting objects. My code seems to be very simple: func deleteProfile(withID: Int) { let fetchRequest: NSFetchRequest<Profile> = Profile.fetchRequest() fetchRequest.predicate = Predicate.init(format: "profileID==\(withID)") let object = try! context.fetch(fetchRequest) context.delete(object) } I did a

Error: Could not build Objective-C module 'Firebase'

梦想的初衷 提交于 2019-12-17 06:26:07
问题 When I compile the application I get an error equal to this: Could not build Objective-C module 'Firebase' This error appear in import Firebase of my file swift. 回答1: There is only one way to solve this issue. Quit Xcode. Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData Delete ProjectName.xcworkspace Delete Podfile.lock file and Pods folder Run pod install . Open the newly created ProjectName.xcworkspace file and build. 回答2: Build ( ⌘ + B ) worked for me. 回答3: I am

What is a good example to differentiate between fileprivate and private in Swift3

旧城冷巷雨未停 提交于 2019-12-17 05:32:31
问题 This article has been helpful in understanding the new access specifiers in Swift 3 . It also gives some examples of different usages of fileprivate and private . My question is - isn't using fileprivate on a function that is going to be used only in this file the same as using private ? 回答1: fileprivate is now what private used to be in earlier Swift releases: accessible from the same source file. A declaration marked as private can now only be accessed within the lexical scope it is

Strange generic function appear in view controller after converting to swift 3

断了今生、忘了曾经 提交于 2019-12-17 05:04:38
问题 In my project, after converting to swift 3, a new function appeared before my ViewController class: fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool { switch (lhs, rhs) { case let (l?, r?): return l < r case (nil, _?): return true default: return false } } What does this function do? Why do I need it? 回答1: That is interesting. Before the latest Swift 3, you could compare optional values, for example let a: Int? = nil let b: Int? = 4 print(a < b) // true and nil was considered

Strange generic function appear in view controller after converting to swift 3

百般思念 提交于 2019-12-17 05:04:23
问题 In my project, after converting to swift 3, a new function appeared before my ViewController class: fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool { switch (lhs, rhs) { case let (l?, r?): return l < r case (nil, _?): return true default: return false } } What does this function do? Why do I need it? 回答1: That is interesting. Before the latest Swift 3, you could compare optional values, for example let a: Int? = nil let b: Int? = 4 print(a < b) // true and nil was considered

Whither dispatch_once in Swift 3?

て烟熏妆下的殇ゞ 提交于 2019-12-17 04:56:10
问题 Okay, so I found out about the new Swifty Dispatch API in Xcode 8. I'm having fun using DispatchQueue.main.async , and I've been browsing around the Dispatch module in Xcode to find all the new APIs. But I also use dispatch_once to make sure that things like singleton creation and one-time setup don't get executed more than once (even in a multithreaded environment)... and dispatch_once is nowhere to be found in the new Dispatch module? static var token: dispatch_once_t = 0 func whatDoYouHear

How to push and present to UIViewController programmatically without segue in iOS Swift 3

旧街凉风 提交于 2019-12-17 04:45:50
问题 I am using this code for push SHOW and MODALLY programmatically in iOS Objective C . And now want to know about Swift 3. NewsDetailsViewController *vc = instantiateViewControllerWithIdentifier:@"NewsDetailsVCID"]; vc.newsObj = newsObj; //--this(SHOW) [self.navigationController pushViewController:vc animated:YES]; //-- or this(MODAL) [self presentViewController:vc animated:YES completion:nil]; 回答1: Push do like let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard