swift UITest: Missing argument for parameter #1 in call [duplicate] - ios

This question already has answers here:
Swift UITesting error: Invalid escape sequence in literal. \U201c
(2 answers)
Closed 7 years ago.
I am running the UITest for my swift project, after i click a UITextField it generated this code:
let secureTextField = app.secureTextFields["\U5bc6\U7801"]
secureTextField.tap()
The error is
/XXXUITests.swift:46:60: Invalid escape sequence in literal,
then i searched and changed ["\U5bc6\U7801"] to ["\u{5bc6}\u{7801}"], i got the error
Missing argument for parameter #1 in call
Any help?

Just not sure why i re-generated the code the error disappeared.

Related

Change color output at console print in Swift [duplicate]

This question already has answers here:
print() to console log with color
(7 answers)
Closed 3 years ago.
I'm writing a command line tool with Swift and I'm having trouble displaying colors in my shell. I'm using the following code:
I trying a lot solution but always the same thing
print("\u{001B}[0;33myellow")
OUTPUT:[0;33myellow
I expect the output is change color in console, is like to logcat
Xcode doesn't support console coloring since Xcode 8
but you can use emojis instead! for example you can use You can use ⚠️ for warning messages and 🛑 for error messages. (like the Xcode itself)
Or simply use these note books as a color:
📕: error message
📙: warning message
📗: ok status message
📘: action message
📓: canceled status message
📔: Or anything you like and want to recognize immediately by color

Swift assign a float variable [duplicate]

This question already has answers here:
Is floating point math broken?
(31 answers)
Closed 3 years ago.
I found a issue that seems strange, or something I don't understand. The following is a very simple variable assignment:
let f: Float = 310.15
In debugger, I see it is 310.149994
I need to send the value as 310.15 to server, but 310.149994 is received instead.
Is this a Swift compiler or runtime bug? Or any way I can ensure 310.15 float is sent? (I cannot change the server API signature)
Try this one
let f : Float = 310.149954
print(round(1000*f)/1000)
result : 310.15

Swift 4: 'substring(to:)' is deprecated [duplicate]

This question already has answers here:
How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator
(21 answers)
Closed 5 years ago.
I'm having trouble converting my Swift 3 code to Swift 4. I've managed to translate everything else in the app successfully, but am having trouble with a single line of code:
cleanURL = cleanURL.substring(to: cleanURL.index(before: cleanURL.endIndex))
The error I'm getting is this:
ViewController.swift:62:33: 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range upto' operator.
Well, do what the error says, use the String slicing subscript (subscript(_:)) with a 'partial range upto' operator (..<, docs, where it's called a 'half open range', oddly enough):
let actuallyCleanURL = kindaCleanURL[..<kindaCleanURL.endIndex]
Note that this returns a Substring. If you need to do more slicing operations, do them on this substring. Once you're done, promote your to a String by running it through the String initializer (String(mySubString)), causing a copy of the memory to be made.

Swift compiler error: missing argument labels [duplicate]

This question already has answers here:
Swift 3 first parameter names
(5 answers)
Closed 5 years ago.
I run Swift on Xcode 8.3.3. Here I get an error regarding closures.
It seems that this part is all correct [var intro = introToFriends("Jim", "Pam")
intro] yet isn't clicking.
What's the issue?
Later Swift versions require explicit argument labels when calling a function. In your case it needs to read:
var intro = introToFriends(friendOne: "Jim", friendTwo: "Pam")
Alternatively, you can allow for omitting the use of argument labels if you add underscores to the parameter labels in the function declaration such as:
func introToFriends(_ friendOne: String, _ friendTwoString) {
...
}
For more details check the official Apple documentation on function argument labels.

Semantic Issue - sizeof not supported in this platform [duplicate]

This question already has answers here:
"Invalid application of 'sizeof' to interface 'Fraction' in non-fragile ABI" in Objective-C
(2 answers)
Closed 9 years ago.
I am having an issue with a xcode project. As I am new on this platform, I nered some help to solve this problem.
XCode Error:
../Classes/CDeck.m:66:37: Application of 'sizeof' to interface 'CCard'
is not supported on this architecture and platform
Code:
-(void) CopyFrom:(CDeck *)Deck
{
Nbr=Deck.Nbr;
memcpy(Cards,[Deck GetByID:0], Nbr*sizeof(CCard)); // Here is the error
}
If you need any information about the project just tell me.
Thanks a lot.
That's because this is not a stack allocated type. Use sizeof(CCard *) to get the size of the pointer (regardless of the heap memory).

Resources