How to make a new line with a UILabel? [closed] - ios

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want the new number to get a new line without removing the old number ?
See the picture

Try
if let exitingText = label.text
{
label.text = exitingText + "\n" + (textField.text ?? "")
}
and set
label.numberOflines = 0

Here is the code you can use on click of button
- (IBAction)btnAppendTextClicked:(id)sender
{
NSString *oldText=_lblWithText.text;
_lblWithText.text=[NSString stringWithFormat:#"%#\n%#",oldText,_txtValues.text];
_lblWithText.numberOfLines=0;
_lblWithText.preferredMaxLayoutWidth =self.view.frame.size.width;
[_lblWithText setNeedsDisplay];
}

Related

iOS Implement SQLite Search Query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I'm working on a search bar within my iOS App and have a SQLite offlite db with about 300k records in it. The text name is how I'd like the search to person. I have the following code working which just does a basic search on String.
func searchList(searchQuery: String, filter: SearchFilter, limit: Int = 20, page: Int = 0) -> outputItems {
guard let db = self.db else { return [] }
var outputTable = Table(OfflineDBSchema.DBTables.outputTable.rawValue)
if !searchQuery.isEmpty {
outputTable = outputTable.filter(OfflineoutputTableColumnExpressions.name.lowercaseString.like("%\(searchQuery.lowercased())%"))
}
I'm looking for a search basic algorithm that is a little bit "smarter" which is better at finding those keywords and returning a results back with most relevant terms at the top.

compression a compound Variable with swift [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
Improve this question
Hello I wrote this little piece of code, but I have the impression that it is not optimal, indeed as the field variable is in get only : I can not directly change it .... but I am junior : so I would be delighted if someone has a better idea :) thank you .
let keyword = ["potatoes","garlic"]
var field: String {
var element = ""
keyword.forEach {
element += "&field=" + $0
}
return element
}
a shorter code coming from professionalswift developper :)
this would be better
let keyword = ["potatoes","garlic"]
var field: String {
return keyword.map { "&field=\($0)"}.joined()
}

How can get unicode of an emoji in ios swift [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am new to swift programming.I am working in an app of emoji.When i click an emoji from Apple keyboard it show the unicode of that emoji.How can i get this.
Here is list of uicodes
https://apps.timwhitlock.info/emoji/tables/unicode
you can also use Edit->Emoji and drag the to the text
let str = "Ti😁 \u{1F601} tle"
use Swift Unicode escape sequence concept:
let emojiString = "\u{1F4C4}"
and if you want to get all emoji's Unicode then try this
let emojiRanges = [
0x1F601...0x1F64F,
0x2702...0x27B0,
0x1F680...0x1F6C0,
0x1F170...0x1F251
]
for range in emojiRanges {
for i in range {
var c = String(UnicodeScalar(i))
print(c)
}
}

Swift, code style/format? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Now that if/for statements have enforced brackets for a code block I have been finding that short 1 line statements quickly start padding out the code. Is it acceptable to format these in a closure type fashion and present them as follows:
var physicsMarker = " "
if (eachChild.physicsBody != nil) { physicsMarker = "*" }
Or is this just going to leave those that look at my code going "What was he thinking" and instead I should stick with the more traditional:
var physicsMarker = " "
if (eachChild.physicsBody != nil) {
physicsMarker = "*"
}
I use the one line style frequently. I think it makes code cleaner and easier to read, especially if you are the only person on the project.
Another style that's similar:
if (eachChild.physicsBody != nil)
{ physicsMarker = "*" }
This calls attention to the identation and has a similar feel to python syntax.
To each his own!

what is the integer (number) equivalent to .text in objective c? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to put a number from a textfield on a Parse database and I need to specify that it is a number. How can I do this?
I have done the equivalent with a string using .text
Your question is unclear but I think you mean something like this:
UITextField *textField = ... // some text field
int age = [textField.text intValue];
user[#"age"] = #(age);
You need to convert the string value from the UITextField to a number, (e.g. int, double, or NSNumber).
NSString *textInput = myTextField.text;
int intValue = [textInput intValue];
NSNumber *age = [NSNumber numberWithInt:intValue];
user[#"age"] = age;

Resources