swift3

Why can't I use the new inline #imageLiteral syntax in Xcode 8? “Expected expression in return result”

不想你离开。 提交于 2019-12-19 17:44:47
问题 I'm trying to use the new #imageLiteral inline image assignment from your assets folder in Xcode 8, where instead of the whole UIImage(named: "") syntax it's just the image displayed, as shown here. But when I do, I get the error "Expected expression in return result" when it's a function. Here's a simple example: func img() -> UIImage { return #imageLiteral(resourceName: "small-checkmark") } Where in Xcode it displays the small-checkmark as would be expected, but it won't compile due to the

How to auto generate NSManagedObject subclasses with date attribute as Date instead of NSDate?

馋奶兔 提交于 2019-12-19 17:33:06
问题 I'm currently updating my project to Swift 3 and I'm moving all my NSDate methods and extensions to Date in order to keep the standard in the app. The problem is that I use Xcode to auto-generate my NSManagedObject subclasses and it is generating the date attributes as NSDate instead of Date. Is there a way to generate it with the date attributes as Date? EDIT Per Apple Developer Documentation: Core Data natively supports a variety of attribute types, such as string, date, and integer

Module compiled with Swift 2.3 cannot be imported in Swift 3.0

偶尔善良 提交于 2019-12-19 14:19:11
问题 i add Facebook SDK (Swift) to my project. And now i update Xcode 8 and Swift 3. I have error in build time Module compiled with Swift 2.3 cannot be imported in Swift 3.0 It is very strange that is not supported. Has anyone had similar problems? 回答1: Remember to set Use Legacy Swift Language Version to YES for your project target You are building your project in 2.3 and not in 3.0 回答2: Have in mind that if you want to use Swift 3 as your main project's language you have to use pods that are

How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8?

为君一笑 提交于 2019-12-19 12:28:34
问题 I'm building a Core Data application using Swift 3 and Xcode 8 beta and when I generate the NSManagedObject subclasses Xcode gives me Objective-C files instead of Swift. While I am very aware that I can simply write my own NSManagedObject subclasses in Swift I'd like to know how to switch the language of the generated code from Objective-C to Swift. Question How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8? 回答1: Alright, apparently I didn't look hard

Swift 3 display all apple emojis in a view

南笙酒味 提交于 2019-12-19 12:01:59
问题 I want to display all the apple emojis in a view in same sequence as displayed here https://emojipedia.org/apple/ with the help of their unicode. I used the following code to implement this. let emojiRanges = [ 0x1F601...0x1F64F, 0x2702...0x27B0, 0x1F680...0x1F6C0, 0x1F170...0x1F251 ] for range in emojiRanges { for i in range { let c = UnicodeScalar(i) print(c ?? "") } } But through this I am not getting expected result. Most of the emojis are missing in between. Please suggest an appropriate

iMessage extension crashes while trying to access UITextView in compact mode

≡放荡痞女 提交于 2019-12-19 11:55:28
问题 Below is the entirety of my code in an iMessage app. class MessagesViewController: MSMessagesAppViewController { @IBOutlet weak var messageView: UITextView! fileprivate func setupMessageView() { messageView.delegate = self messageView.layer.cornerRadius = 10 messageView.layer.borderColor = UIColor.black.cgColor messageView.layer.borderWidth = 5 messageView.text = "Tap to enter a message" messageView.textColor = UIColor(red:0.80, green:0.81, blue:0.82, alpha:1.0) messageView.textAlignment =

Rotating image by 3*Double.pi/2 makes image not appear (swift3)

橙三吉。 提交于 2019-12-19 11:49:11
问题 Trying to rotate my image orientation by 270 degrees I can rotate by 90 degrees and the image appears however when rotating the image by 270 nothing happens. I have added 2 pictures of the 90 and 270 degrees commands to make things more clear. extension CIImage { var image: UIImage? { return UIImage(ciImage: self) } var rotatingLeft: CIImage? { let transform = CGAffineTransform(translationX: extent.midX, y: extent.midY) .rotated(by: CGFloat.pi.divided(by: 2)) .translatedBy(x: -extent.midX, y:

Returning the subclass in a UIViewController static

放肆的年华 提交于 2019-12-19 11:43:57
问题 Consider a base UIViewController class... class Rooms: UIViewController { class func instantiate()->Rooms { } static func make()->Rooms { let emplacedAndSetup = self.instantiate() // various kodes here // very likely put s.view somewhere return emplacedAndSetup } sundryOtherFunctionality() } (Note the self. before instantiate() which seems to be necessary to get "that" instantiator.) Each subclass knows its own storyboard ID to how use to instantiateViewController : class Dining: Rooms {

WebService API Method in Swift 3 and Swift 4?

穿精又带淫゛_ 提交于 2019-12-19 11:36:53
问题 I am new to Swift iOS and i want to create a separate method in separate class(like NSObject ) of web services so that i can use it in any ViewController and parse any type of JSON response using NSURLSession and Alamofire . Could someone help me. 回答1: class WebRequester: NSObject { static let shared = WebRequester() let session = URLSession.shared func request(urlStr:String, parameter:String, token:String? = nil, callback:@escaping (_ result:NSDictionary?, error:Error?) -> Void) { let url =

Swift 3 NTLM authentication

元气小坏坏 提交于 2019-12-19 11:21:02
问题 For a recent project I tried to pull some data from a server in the SOAP and oData format respectively, that is protected with a Microsoft NTLM authentication, and it has been a nightmare figuring out how to do it, none of the online examples really worked. 回答1: So here is my solution; I had to adapt, expand and combine a few different sources. I hope this helps someone in the future. // // ViewController.swift // ntlm // // Created by Kamik423 on 21.3.17. // Copyright © 2017 Kamik423 All