Linked Questions
10 questions linked to/from How should I remove all the leading spaces from a string? - swift
0 votes
2 answers
128 views
Issue in removing spaces from string in swift [duplicate]
i'm getting my contacts number locally from my mobile. There are some number in which there are white spaces between numbers. I'm trying to remove the white spaces from the number but it isn't working,...
436 votes
16 answers
231k views
Does Swift have a trim method on String?
Does Swift have a trim() method on String? For example: let result = " abc ".trim() // result == "abc"
113 votes
11 answers
36k views
Computed read-only property vs function in Swift
In the Introduction to Swift WWDC session, a read-only property description is demonstrated: class Vehicle { var numberOfWheels = 0 var description: String { return "\(...
19 votes
6 answers
21k views
Remove whitespace character set from string excluding space
How can I remove the whitespace character set from a string but keep the single spaces between words. I would like to remove double spaces and triple spaces, etc...
-1 votes
3 answers
1k views
Remove all the spaces from a string at the beginning or end - swift
How can I remove all white space from the beginning and end of a string? Like so: "Test User Image" returns "Test User Image" "Test User Image " returns "Test User ...
1 vote
1 answer
1k views
UILabel shows more white space in top and bottom for long text
I want to display attributed text label inside a scrollview. I use the following code the label displays the text in centre and some extra white space is added in top and bottom. NSString *...
2 votes
2 answers
201 views
Cleanest way to remove trailing blanks a string in swift?
In Perl if I had trailing blanks in a string, I would use this code $line =~ s/ +$//; Is there a similar command or function in swift?
-1 votes
1 answer
340 views
Searching Safari For A Keyword Instead Of URL In Swift
Im trying to make an app that opens the safari app and searches for a specific keyword. I know how to open Safari and search a URL, but is there any way to do it with just a keyword?
-1 votes
1 answer
115 views
How to convert any textfield input to float in Swift
I want to store float to CoreData and I want to convert every of the following inputs to 90.5: 90.5 90,5 90.5 90, 5 That means: Remove whitespace and convert , to . Is this code best practice? let ...
0 votes
2 answers
69 views
get url from String using URL(string: ) constructor
I'm creating a function which makes an API request. The function receives a parameter and put it inside the API call. It is like this: static func queryCities(cityNameString : String, completion: @...