Most voted "swift" questions
Swift is a multi-paradigm programming language for Apple’s iOS and macOS operating systems. It was created by Chris Lattner in 2010 and released on Apple’s WWDC on 06/02/2014. It is currently in version 5.
Learn more…491 questions
Sort by count of
-
14
votes4
answers1231
viewsVery interesting switch/case on Swift - What other languages support this?
The Swift language presents a very interesting and very intuitive way to work with intervals using switch-case, with "partial matching" techniques, "Pattern-matching" etc, look at these examples:…
-
8
votes1
answer91
viewsType Int8 on Swift does not store maximum integer 255
Doing some pranks on the Playground, With Swift 2.2 we can declare constant let testeIntOitoBits: Int8 = 127 //maximo - deveria ser 255 let testeIntOitoBits2: UInt8 = 255 Why can’t I store 255 in…
-
7
votes3
answers2732
viewsWhen and how to use protocols and delegates?
Could someone please explain to me in what situation and how to use delegates and protocols, I’m a little confused when to what I’ve read around, Thank you!
-
7
votes2
answers1003
viewsSwift 3 / Xcode 8 - How to change the native language of my App?
I’m finishing an application and I couldn’t help but notice that some components of my app are in English: How to change the app’s native language? How to make it change automatically according to…
swiftasked 7 years, 9 months ago outrowender 164 -
6
votes1
answer145
viewsIOS - How to make the app screen always lit?
I’m making an app for IOS I already have ready on Android, I wanted to make a method that left the screen always lit, but I’m not getting On Android I did this way: Mainactivity: PowerManager pm =…
-
6
votes2
answers4772
viewsCPF and CNPJ validation
I’ve been doing research on Swift and I haven’t seen examples that contemplate the validation of both CPF and CNPJ. So any of your colleagues have a function that can validate them?
-
6
votes2
answers204
viewsProject Alamofire conversion to Swift 3.0
I have the following code when I want to make a call to the server: let mutableURLRequest = NSMutableURLRequest(url: URL) mutableURLRequest.httpMethod = "POST" let parameters = ["SessionID":…
-
6
votes1
answer304
viewsWhat are the delegates?
In iOS programming it is common to use structures that act as delegates. One of them, for example, is the UITextFieldDelegate. This class, according to documentation, informs the implementor of…
-
5
votes1
answer323
viewsHow to get SHA1 from a String in Swift?
I know there’s an object SHA1 but I’m still learning the syntax, so, my beginner question is, given a simple string: var greeting = "Hello!" How to get SHA1 from greeting in Swift?…
-
5
votes1
answer439
viewsDo I need a macOS computer to program Swift 4 and Objc?
I’m doing a lot of research on iOS app programming, and all the online courses I find on the computers are Apple-based. To program Apple, you need an Apple computer?
-
5
votes1
answer124
viewsResized screen after upgrading Xcode to version 11
After upgrading the Xcode to version 11, the App developed for Ipad does not behave in a maximized way on the screen when running, both in the simulator and on the device, but the storyboard is…
-
4
votes3
answers619
viewsRotation on certain screens
How do I define only one UIViewController be able to rotate? The scenario is as follows: I own 5 screens, and in all of them I must enable only the mode portrait. But I have a sixth screen, and this…
-
4
votes1
answer726
viewsLabel auto fit with Swift text size?
I have a label inside a scrollView, and this label gets an N text, some are small and some are big so the idea was to put in scrollView, but the problem is that I can’t adjust the label to increase…
-
4
votes2
answers166
viewsIOS - How to scale a view by Swift?
I have a view called viewV and would like to change your Width and Height shown in the image below via Swift code.…
-
4
votes1
answer287
viewsSave latitude and longitude in Swift
I have this code in my Viewcontroller to capture the current location of users: @IBOutlet weak var userMapView: MKMapView! var locationManager = CLLocationManager() override func viewDidLoad() {…
-
4
votes1
answer364
viewsWhat is the difference between viewDidLoad and awakeFromNib?
What is the main difference between viewDidLoad and awakeFromNib in development on Swift for iOS?
-
3
votes1
answer215
viewsprintln on Swift via terminal
I’m trying to compile a class people.swift for Terminal macosx class People { let name:String = "" let age:Int = 0 init(name:String, age:Int) { self.name = name self.age = age } let anyPeople =…
-
3
votes1
answer709
viewsTurning user input into button label
Guys, I’m trying to create a button that when pressed enables a text field that should take the user input and change the button label to input, but when I tried to play only got the following…
-
3
votes1
answer693
viewsHow to test Swift connection
I have a very simple webview, and before loading the webview I want to check the connection, if it is unavailable create a message for the user informing.
-
3
votes1
answer780
viewsHow to integrate Objective-C and Swift?
I am doing a project on Swift and would like to use some files in Objective-C. It is possible to do this? In case I installed using the Cocoa Pods, I don’t know if it influences anything.…
-
3
votes1
answer92
viewsCreating a custimized authorization message
Is there any way to customize the authorization message to requestWhenInUseAuthorization and requestAlwaysAuthorization? I know for this to work we have to add in info.plist the information…
-
3
votes3
answers522
viewsValidation of Fields in Swift
How to validate fields using Swift? I intended to do with Exception, but I just searched and found that Swift has no Exceptions... I’d like something like that: void onCadastrar(dados){ try {…
-
3
votes1
answer70
viewsDo Swift apps work on an iPhone 4 with iOS 7?
Setting: An iPhone 4 operating with iOS 7 can run app’s developed with Swift? NOTE: I’m not referring to 4S, only 4.
-
3
votes2
answers111
viewsThread in the background when the app is closed
How do I run a Thread with the application closed? That is, so that when the user turns on the device it starts without having to enter the application.
-
3
votes1
answer250
viewsExecute a method with the closed application "Service"
On Android it is possible to send notifications, make queries via http, execute methods, all through a Service without the user need to necessarily run the application, just the fact that the…
-
3
votes1
answer80
viewsError Cannot invoke initialize for type "Cllocationcordinate2d" with an argument list of type "latitude : String"
I’m developing an app that captures user location with Core Location and saved in a file. Now I have a mapview and need to display this location on the map (this location comes from the archive).…
-
3
votes3
answers1491
viewsHow to round Double values?
I made a function to return the rounding of values of type Double, the function is working, but I do not know if it is the ideal way to have this result, I think there must be a way without having…
-
3
votes1
answer73
views"unwrapping an Optional value" error in login screen transition
Whenever I will do the screen pass with login and password my application to with the error below: fatal error: unexpectedly found nil while unwrapping an Optional value Function Signature…
-
3
votes1
answer692
viewsHow to count how many characters a string has - Swift
I’m having some difficulties with simple things. How do I count how many letras has a variable? let word = wordEasy[0] for var i = 0; i < word.count ?????…
-
3
votes3
answers1628
viewsHow do I export a trial app without the apple Developer program?
I’m concluding an app on Swift 2 IOS and would like to know if there is how to export and install on an iphone without having apple Developer program, as can be done on android.
-
3
votes1
answer370
viewsVariable declaration with ! at end Swift 3
Why in some variable statements in Swift3 an exclamation mark is added (!)? For example: var _nome: String! var _idade: Double! What does this entail of differences? When to use?…
-
3
votes2
answers313
viewsHow to attach images from camera or gallery to Swift
Good morning guys, I am developing an application in Swift, but I am new in the language and do not know some things, I would like to know how I attach the images from my gallery or open the mobile…
swiftasked 7 years, 3 months ago Junior Sanches 31 -
3
votes1
answer361
viewsWhat is protocol-oriented programming?
I would like to know, what is protocol-oriented programming? I heard a teacher comment about this type of programming, about this paradigm, but it was a little vague.
-
3
votes1
answer233
viewsDifferences between tableView.dequeueReusableCell and Uitableviewcell
Good night, I would like to know what is the difference between the parameters below, if one is but effective than the other, less chances of error etc. From what I see in practice both do the same…
-
3
votes1
answer139
viewsClose app on Swift
I am starting in Swift programming and my question is how to close the application. For example, on android, used the System.exit(0) has something like me Swift?
-
2
votes2
answers141
viewsHow to access a Cocoa Touch Framework module on Playground Swift
I created a Cocoa Touch Framework module on Xcode 6.0.1 with Class implemented in Swift and can matter in my View Controller and use it normally. The problem that I can’t use the same code in the…
-
2
votes0
answers1349
viewsobjective c or Swift?
Hello, I’m starting now to program for Ios, I’m already an android java programmer, and wanted to know at the moment which best to develop applications for apple (iphone/tablet) and I saw that apple…
-
2
votes1
answer51
viewsImporting an objc control into Swift: Error when putting an action (func) of my contole
I decided to make an app in Swift this time, and as usual I use my custom control (Menuview). In objc I know how it works and everything worked, in Swift I followed all the steps, import in…
-
2
votes2
answers6761
viewsMask for Uitextfield
How to apply mask on a UITextField? I found some ways to apply a mask on a UITextField, but it did not seem to me something very correct to do. It can be an example of telephone mask, very simple.…
-
2
votes1
answer375
viewsBest data persistence practice
When it comes to persisting the data with the Core Data. What is the best way to persist the data? For example: I own an object Pessoa (subclass of NSObject). And at the time of persistence I…
-
2
votes1
answer549
viewsCalling dictionary in another View Controller Swift
I am trying to pass a dictionary from one Viewcontroller to another, I have succeeded, but the dictionary I am passing through is empty. I want to pass the dictionary after adding the userinput when…
-
2
votes2
answers180
viewsHow to delete Tableviewcell as a Swift Dictionary
I’m trying to rule out a TableViewCell using Swipe to delete style, but I cannot delete Cells. Cells are being created by a dictionary that creates each with the key as title and value as details.…
-
2
votes1
answer229
viewsMkmapview circular Swift
I wonder if you can leave Mkmapview in Xcode with circular format. I tried to use mapView.layer.cornerRadius, but I still could not
-
2
votes1
answer64
viewsColors in images
I have an image and would like to take the predominant color of this image. For example: I have this image:…
-
2
votes2
answers838
viewsMap showing search location Swift
Guys, I’d like to know how I can get my map to show the place that was searched and center the view at this point. I was able to do with the current location as follows:…
-
2
votes1
answer140
viewsOutlets in Xcode 6 (Universal Application)
I have a problem/doubts. Until today due to some needs I developed only for iPhone or iPad separately, but today I’m starting in the development of universal application, iPhone and iPad. I’m using…
-
2
votes1
answer103
viewsMotion sensor
How do I identify the rotational motion of the iPhone on its own axis (same rotation as a spinning top)? I was able to identify practically all possible rotations and I couldn’t identify this one,…
-
2
votes1
answer78
viewsWindow to save Swift File
I would like to create a window to save text files on disk, but do not know how to create a File Explorer using Storyboard.
-
2
votes1
answer914
viewsHow to calculate the distance between two location points?
I need to calculate the shortest distance between two locations obtained automatically through the CoreLocation. To be more specific, the idea is to mark a starting point and after the user "walk" a…
-
2
votes1
answer174
viewsHow do I open a Viewcontroller via Local Notification?
I have an application that sends notifications to the user from time to time, but how do I open a View without being the main View, when the user clicks on the notification? Example, Whatsapp…