NSString with lines through each letter [duplicate] - string

This question already has answers here:
How can I create a UILabel with strikethrough text?
(21 answers)
Closed 8 years ago.
How can I write a string like the following:
H̶̶o̶̶w̶ ̶t̶̶o̶ ̶w̶̶r̶̶i̶̶t̶̶e̶ ̶t̶̶h̶̶i̶̶s̶ ̶t̶̶e̶̶x̶̶t̶
In my app, I need to display the past price of a product that has been replaced by a new price. Like so:
$̶8̶̶0̶̶0̶ -> $600

To get this result you should use NSAttributedString and set the attribute name NSStrikethroughStyleAttributeName. The number used as object for this key defines the style of the line over the text.
self.myLabel.attributedText = [[NSAttributedString alloc] initWithString:#"800" attributes:#{NSStrikethroughStyleAttributeName: #1}];
Cheers

Related

split every single character in string. VBA.net [duplicate]

This question already has answers here:
Split string into array of characters?
(7 answers)
Closed 3 years ago.
can you help me on this?
I have a simple string:
str="Hello World";
I want to split it as that :
array= str.Split("",System.StringSplitOptions.RemoveEmptyEntries);
result shoud be
array[0]="H"
array[1]="e"
array[2]="l"
array[3]="l"
array[4]="o"
array[5]="W"
array[6]="o"
...
But I don't know to "wildcard" the separator..
Any Idea on this ?
Thanks
?
Just use String.ToCharArray():
SomeArray = str.ToCharArray()

Dart - How to Insert "$" word in String? [duplicate]

This question already has answers here:
How do you print a dollar sign $ in Dart
(2 answers)
Closed 4 years ago.
I'm currently creating an simple application with flutter(Dart). And when i want to create the AppBar widget, i cant give it names with '$'. Because, same like Kotlin..Dart is using '$' for summoning an identifier.
Any solution?
var _appbar = AppBar(
title: Text("How I Made $100"), //$ is the error
);
The dollar sign is a special character, so if you want it to be ignored you have to escape it with a \.
For example:
void main() {
print("This string contains a dollar \$ign");
}
See this gist.

Finding if a string contains a string in Swift 2.1 [duplicate]

This question already has answers here:
How do I check if a string contains another string in Swift?
(28 answers)
Closed 7 years ago.
The answer in this question: How do I check if a string contains another string in Swift?
No longer works.
var string = "hello Swift"
if string.rangeOfString("Swift") != nil{
println("exists")
}
Will get you:
error: value of type 'String' has no member 'rangeOfString'
What is the new way to do this?
Import Foundation and you will be able to call rangeOfString.

mongodb get first element after find query [duplicate]

This question already has answers here:
How to get the last N records in mongodb?
(16 answers)
Closed 7 years ago.
I can't find the answer. I have a query that can return many answer and I want to get the last one. How to do it?
db.users.find({username: "bob", sort: {createdAt: -1}}).first()
I would like something like this.
do this to get last N records :
function last(N) {
return db.collection.find().skip(db.collection.count() - N);
}

Illegal string offset 'handler' in PHP [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
Please how can I correct this error:
Warning: Illegal string offset 'handler' in /home/***************/public_html/whois/phpwhois/whois.gtld.php on line 95
on the following code:
function parse($data, $query)
{
$this->Query = array();
$this->SUBVERSION = sprintf("%s-%s", $query["handler"], $this->HANDLER_VERSION);
$this->result = generic_parser_b($data["rawdata"], $this->REG_FIELDS, 'dmy');
Please check if $query is a string if it is then the code will not work. Make sure you pass $enquiry as an array or fire an exception.

Resources