swift3

Swift 3 json parsing

允我心安 提交于 2019-12-30 13:14:03
问题 I am running into troubles updating my app as Alamofire and SwiftyJSON are not yet supporting Swift 3. I have a url that would return me json as follows: { "products": [ { "body_html":"", "created_at":"2016-03-02T13:56:18+03:00", "id":489759251, "handle":"product", "options":[ { "id":627488838, "product_id":489759251, "name":"Title", "position":1, "values":[ "Default Title" ] } ], }, { "body_html":"", "created_at":"2016-03-08T05:17:55+03:00", "id":530420915, "handle":"product-2", "options":[

Swift 3 json parsing

时光怂恿深爱的人放手 提交于 2019-12-30 13:13:10
问题 I am running into troubles updating my app as Alamofire and SwiftyJSON are not yet supporting Swift 3. I have a url that would return me json as follows: { "products": [ { "body_html":"", "created_at":"2016-03-02T13:56:18+03:00", "id":489759251, "handle":"product", "options":[ { "id":627488838, "product_id":489759251, "name":"Title", "position":1, "values":[ "Default Title" ] } ], }, { "body_html":"", "created_at":"2016-03-08T05:17:55+03:00", "id":530420915, "handle":"product-2", "options":[

Why is Calendar.date(from: DateComponents) adding time?

守給你的承諾、 提交于 2019-12-30 11:32:11
问题 I create an instance of DateComponents using the following code: let dateComponents = DateComponents( calendar: .current, timeZone: Calendar.current.timeZone, era: nil, year: nil, month: nil, day: nil, hour: 9, minute: 0, second: 0, nanosecond: 0, weekday: 2, weekdayOrdinal: nil, quarter: nil, weekOfMonth: nil, weekOfYear: nil, yearForWeekOfYear: nil) I then print the dateComponents object and get the following (expected) output: calendar: gregorian (current) timeZone: Europe/London (current)

Swift 3. NSFetchRequest propertiesToFetch

久未见 提交于 2019-12-30 11:16:08
问题 In Swift 3 when we use NSFetchRequest , we have to specify NSFetchRequestResult . But how to get an array of properties values? If I use something like this let fetchRequest = NSFetchRequest<MyClass>(entityName: "MyClass") fetchRequest.propertiesToFetch = ["myAttributeName"] an exception fires when I try to execute fetch request. error: -executeRequest: encountered exception = The database appears corrupt. If I remove a line with propertiesToFetch I don't get any errors, but I get an array of

Restrict the number of characters in UITextField [duplicate]

北城以北 提交于 2019-12-30 11:15:30
问题 This question already has answers here : Set the maximum character length of a UITextField (44 answers) Closed 3 years ago . I've seen a lot of answers, but it seems that none of them has worked. I have a programmatically created UIAlertView with two UITextFields. I want to restrict the number of characters : 12 characters in first field 1 character in second field First field code: alertDialog.addTextField { (nameField) in nameField.placeholder = "Name" nameField.borderStyle = .roundedRect

Restrict the number of characters in UITextField [duplicate]

我的未来我决定 提交于 2019-12-30 11:15:10
问题 This question already has answers here : Set the maximum character length of a UITextField (44 answers) Closed 3 years ago . I've seen a lot of answers, but it seems that none of them has worked. I have a programmatically created UIAlertView with two UITextFields. I want to restrict the number of characters : 12 characters in first field 1 character in second field First field code: alertDialog.addTextField { (nameField) in nameField.placeholder = "Name" nameField.borderStyle = .roundedRect

How to add two or more buttons to annotationView: MKAnnotationView?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 11:02:09
问题 I want to have a MKAnnotationView to my pins on map (using MapKit) with next attributes: 1) image 2) details button 3) another details button 4) another details button? I have done actually adding image and details button with next code: annotationView.detailCalloutAccessoryView = snapshotView // snapshot view is a custom view // with image and its constraints let detailsButton = UIButton(type: .detailDisclosure) annotationView.rightCalloutAccessoryView = detailsButton So, the question is how

fatal error: use of unimplemented initializer 'init(size:)' for class

怎甘沉沦 提交于 2019-12-30 08:13:09
问题 I was testing my app on different devices and realized the sprite movements were quite inconsistent (running considerably faster on some devices as compared to others). I found this post and followed the instructions and removed the size parameters from all my SKScene s then I got the error: fatal error: use of unimplemented initializer 'init(size:)' for class 'SuperGame.PosterScene' Please see my PosterScene class below and the GameViewController class in which it is called. PosterScene

How pass data to an UICollectionView embedded in a TableViewCell (xCode - iOS - Swift 3)

馋奶兔 提交于 2019-12-30 07:34:49
问题 I implemented a CollectionView in a TableViewCell but I need read dynamic data for set cells on CollectionView. I can read data on extension from class TableViewCell, maybe can help me pass data from ViewController to the class TableViewCell. class MultipleTableViewCell: UITableViewCell { @IBOutlet fileprivate weak var collectionView: UICollectionView! } extension MultipleTableViewCell : UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView,

How pass data to an UICollectionView embedded in a TableViewCell (xCode - iOS - Swift 3)

↘锁芯ラ 提交于 2019-12-30 07:34:33
问题 I implemented a CollectionView in a TableViewCell but I need read dynamic data for set cells on CollectionView. I can read data on extension from class TableViewCell, maybe can help me pass data from ViewController to the class TableViewCell. class MultipleTableViewCell: UITableViewCell { @IBOutlet fileprivate weak var collectionView: UICollectionView! } extension MultipleTableViewCell : UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView,