Posts by Leo Dabus • 1,109 points
31 posts
-
2
votes2
answers75
viewsA: How to create a variable that only increases equal to an ID in Swift 4?
It may seem complicated, but it’s quite simple: Each time you access the user’s own counter defaults, add 1 to the result, save the new value in the user’s preferences (Userdefaults) and then return…
-
1
votes2
answers511
viewsA: iOS: open pdf of webview in browser OR download pdf
What you really need is to monitor the user’s navigation. You can do this in Uiwebview as well but Uiwebview ta deprecated so I recommend using Wkwebview for this: import UIKit import WebKit class…
-
0
votes2
answers196
viewsA: Bring item from an API in Swift
Response taken into account published code here. Your problem is that you’re running an unsynchronized method so when Voce Tenth print the result after starting your get the result kinda Naoto…
-
0
votes1
answer395
viewsA: Swift 4 http get and iterate the JSON response
You can use a method of JSONSerialization called jsonObject(with: Data) that Convert the data returned by the API in an Object of type Any. Then you need to cast the type Any for dictionary…
-
1
votes1
answer387
viewsA: remove parts of a string and return the removed parts - Swift
This is much more complex than it looks, but I will try to explain in detail the step by step. First you need to change the type of your function parameter to ... which in this case is called…
-
1
votes3
answers330
viewsA: Array Pose in Swift
Andreza’s answer is correct, but if you need to know the position of an element within a loop you need to use the method enumerated in your array. var nomes = ["Douglas", "Marilia", "Roberto",…
-
5
votes1
answer243
viewsA: Error: Expression implicitly coerced from 'String? ' to Any
The problem is that the property text of your field is of optional type String? and Swift is an inferred type language. So the type of your phrase object will also be String?. For this not to happen…
-
1
votes1
answer41
viewsA: How to copy certain Bytes of a Date type in Swift
The problem is that Voce is trying to force newNumbers to be of the type Data but the result of the subscript is of the type MutableRangeReplaceableRandomAccessSlice. Simply Voce initialize a new…
-
0
votes4
answers364
viewsA: Swift 3 - How to persist objects
There are some problems in your class, especially in the initializer of your class. In the part of Decoding Voce you must use the decodeDouble(forKey:) method instead of using decodeObject. By…
-
1
votes2
answers175
viewsA: How to share a pdf that is on a Swift webview
You must use the specific apple framework to compose messages called Messageui. To attach a file to an email You need to read the data in your pdf and use the addAttachmentData method to attach it…
-
1
votes1
answer74
viewsA: Share a pdf file in Swift by email
You must use the Messagesui api to compose the email pro user as follows: import MessageUI class ViewController: UIViewController, MFMailComposeViewControllerDelegate { override func…
-
2
votes2
answers80
views -
2
votes2
answers75
viewsA: Error Scanning Evreflection Bool
I don’t know anything about Evreflection, but I can help you serialize your json using Swift Jsonserialization native API to convert json data: First Voce should get used to always using structs…
-
25
votes2
answers4772
viewsA: CPF and CNPJ validation
CPF validation To validate the first digit of the Voce CPF you need to multiply each digit (from 1º to 9º) starting with 10 and gradually decreasing to 2 and accumulating the total of the…
-
1
votes1
answer158
viewsA: Problem when doing POST method on Swift
As you did not specify the version of your Xcode I will reply with the code to the current version of the App Store (Xcode 8.2.1 • Swift 3.0.2). I have put the Communications on the following…
-
1
votes1
answer238
viewsA: How to pass a value from a dictionary (which is inside another dictionary) to a Label? Swift 3
You need to cast your Any elements to the type of your element: Try as follows, if Voce has trouble Parsing your dictionary in one conditional, best break-down the code below: let dict: [String:…
-
1
votes2
answers126
viewsA: Swift Way to display variables
The native Swift type is not Nsstring, but String. All initializers available for Nsstring also exist for String. If you want to put the text of your text field directly in your string you have to…
-
2
votes2
answers204
viewsA: Project Alamofire conversion to Swift 3.0
Swift 3 you must use Urlrequest instead of Nsurlrequest. When it is Nsmutableurlrequest you should also use Urlrequest but as Urlrequest is a Structure and not a class to be able to change its…
-
0
votes1
answer120
viewsA: Real-time validation of a textField
If you need to make a field for input of integer numbers you can simply subclass Uitextfield and customize your field within the awakeFromNib method and you can also add addTarget to Uicontrolevents…
-
2
votes1
answer122
viewsA: Popover menu IOS Swift
What you need to implement is actually called Uialertcontroller: func displayAlertMenu() { let alert = UIAlertController(title: "Selecione a origem", message: nil, preferredStyle: .actionSheet) let…
-
1
votes2
answers64
viewsA: Variable does not appear as declared
I suggest you use a method called String Interpolation which enables you to use any type that conforms to the protocol CustomStringConvertible (String, Double, Int, etc.). To insert your variable…
-
5
votes1
answer464
viewsA: How to change the color of the Ios navbar
The problem is that Voce has to pass a value between 0.0 and 1.0. If Voce passes any value above that it interprets as 1. let corBarra = UIColor(red: 24/255, green: 27/255, blue: 113/255, alpha: 1)…
-
3
votes3
answers1761
viewsA: How to convert a String to Date on Swift
For this date format 2016-08-14T20:38:27.031-03:00 iso8601, Voce needs to use the following format with thousandth of seconds SSS and XXX for time zone (-03:00 or Z): "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"…
-
0
votes1
answer690
viewsA: Post request on webservice with Swift
Don’t rely 100% on syntax because I wrote it directly in the browser and I’ve only been programmed using Swift 3. It should be enough to give you an idea of what Swift needs, but it’s not a task for…
-
2
votes1
answer37
views -
0
votes2
answers489
views -
0
votes3
answers210
viewsA: How to recover the first letter of a Swift array
You can extend the Array type using where clause to extend only elements that can be converted to String. Create a property to return an array of Strings. Use map to convert each element to String,…
-
4
votes1
answer707
viewsA: How to pick specific letters from a string - Swift2
You can access the property characters of a String and use it to extract a array of your characters. If you want a array of String for each Character you need to use the method map to transform the…
-
3
votes2
answers1964
viewsA: Consume Json Data - Webservice Swift 2 - iOS
You can use Nsurlsession dataTaskWithURL and create a method to asynchronously download the data as follows: func searchBuscape(query: String) { guard let escapedSearch =…
-
1
votes2
answers79
viewsA: Is it possible to convert an array [Any] to Nsdata?
You should first extend Integertype to be able to extract your bytes in Nsdata form using getBytes and use dynamicType sizeof() to determine the byte length: extension IntegerType { var data: NSData…
-
1
votes1
answer383
viewsA: Check URL loaded in a Webview
You need to make your View Controller fit the Uiwebviewdelegate protocol First add Uiwebviewdelegate to the view controller that contains your uiwebview class ViewController: UIViewController,…