Questions tagged [swift3]

Use this tag only for questions directly related to changes in version 3 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc for questions about developing on Apple platforms.

Swift 3 is the version of Apple's programming language Swift. It was released on September 13, 2016. The language is open source and available on Github (see ).

The development of Swift 3 and its goals can be viewed on the Swift Programming Language Evolution repository on Github.

For more information, please visit Swift's Getting Started page.

18453 questions
5
votes
2 answers

Format date string as per device locale settings

I have to format the date string (UTC format) as per device locale settings. For example in India it should display as 08/09/2017 12.23 and in US it should display as 09/08/2017 12.23, Based on different region setting it should display the date…
Warrior
  • 39,156
  • 44
  • 139
  • 214
5
votes
4 answers

programmatically set a button width and height

I would like to programmatically customize the UIButton. My code starts here: class MyButton: UIButton { override func awakeFromNib() { super.awakeFromNib() layer.shadowRadius = 5.0 ... } } Now I would like to…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
5
votes
2 answers

GraphQL Apollo iOS Client Response Headers

I am using Apollo iOS client for doing GraphQL queries. I need to pass Auth token in the header which I am able to achieve using below code - let apolloAuth: ApolloClient = { let configuration = URLSessionConfiguration.default …
Kapil G
  • 4,081
  • 2
  • 20
  • 32
5
votes
3 answers

A swiftier way to convert String to UnsafePointer in Swift 3 (libxml2)

I'm working on a Swift 3 wrapper for the libxml2 C-library. There are two convenience methods to convert String to UnsafePointer and vice versa. In libxml2 xmlChar is declared as unsigned char. UnsafePointer to String is…
vadian
  • 274,689
  • 30
  • 353
  • 361
5
votes
1 answer

UIWebView play audio when app goes to background

I'm using YouTube iOS Helper Library to play a video inside a WKWebView and I want the audio to continue playing even when HOME is pressed or lock key. Capabilities tab looks like this: I have also imported import AVFoundation inside…
M1X
  • 4,971
  • 10
  • 61
  • 123
5
votes
1 answer

priority and background was deprecated in ios 8

I have an app that is developed with old swift code. now I'm updating it to latest swift syntax. While updating I found difficult in dispatch queue, here it's giving two warnings as global(priority) was deprecated in ios 8 and background was…
iOSDude
  • 274
  • 2
  • 25
5
votes
1 answer

IOS swift avplayer inside UiView how can I make it work

I am new to using the AVPlayer for IOS swift and got it working correctly. However I would like the video to play inside a UIView right now the video takes up the whole page as default . I have been trying a few things and nothing works here is my…
user1591668
  • 2,591
  • 5
  • 41
  • 84
5
votes
2 answers

How to compress data in swift 3?

I have some files in file manager in Swift 3. I want to upload them, but when I will convert them into base 64, their size will be huge! so I want to compress the data before converting it into base 64. Here is my code for converting: for i in…
Saeed Rahmatolahi
  • 1,317
  • 2
  • 27
  • 60
5
votes
2 answers

Passing variables by reference in Swift

I started learning c++ and now I am wondering if I can do some things in Swift as well. I never actually thought about what happens when we pass a variable as an argument to a function in Swift. Let's use a variable of type string for examples. In…
Alexei
  • 511
  • 1
  • 10
  • 22
5
votes
0 answers

Segmentation fault error on migration from SWIFT 2 to SWIFT 3

Thoroughly searched for this question but was not able to find it in Stack Overflow. Getting segmentation fault error: 1. While type-checking getter for asset at Below is the code of the class for which I am getting Segmentation…
Kunal Das
  • 51
  • 2
5
votes
5 answers

Detect current page of UIPageViewController

I want to detect the current page in order to modify a button's title while the last page is showing and re-modify every time the user swipes back from the last to the second to last page. Now these are my delegate methods and my array of…
Elia Crocetta
  • 318
  • 1
  • 6
  • 20
5
votes
1 answer

Can't dismiss MFMailComposeViewController in Swift 3.0

The MFMailComposeViewController cannot be dismissed after pressing cancel or send button. I have added MFMailComposeViewControllerDelegate in my class but still, it's not working? Here is my code: func sendEmail() { let MailVC =…
5
votes
3 answers

How to center justify text in UITextView?

I have an Arabic (right to left) text in textView, when I set myTextView.alignment = .justify, the last line in text go to the left side. How can I set center justify for textView or how can move last line to the center?
5
votes
0 answers

AVAudioEngine, AVPlayer, AVPlayerViewController - Control Center controls becomes disabled when AVPlayerViewController plays video

I am using AVAudioEngine to play audio files and AVPlayer and AVPlayerViewController to play videos. and Control Center notification are enabled UIApplication.shared.beginReceivingRemoteControlEvents() Control Center works perfectly for audio files…
PGill
  • 3,373
  • 18
  • 21
5
votes
2 answers

Swift 3 select multiple photos using UIImagePickerController

I have a UIImagePickerController which with it I select a photo from Library, or take a photo with Camera and then show the selected photo in a UIImageView. I want to upload this photo later to an API (which still don't know how to upload photos,…
Abed Naseri
  • 512
  • 2
  • 10
  • 18