Sorry, but I cannot understand what you want to do.Say the values, please explain the values of what? About it, what are those all its here and there?Maybe showing more code, even if it does not work as you expect, would help readers understand what you want to do.
Post
Replies
Boosts
Views
Activity
Can you show more examples?Let's say we have:let arrayValues = ["apples", "bannanas", "cherry", "date", "eggplant", "dorito"]
let x = 1
let y = 3Then, what is the desired output? Some boolean value `true` or `false`? An array? Or some integers?Please show some examples, input(s) - output(s). You should better omit intermediate values and just show the final result.
My problem is that this method never gets called. Any thoughts?Please clarify which method do you mean by this method. "navigationControllerSupportedInterfaceOrientations" or preferredInterfaceOrientationForPresentation?Assuming navigationControllerSupportedInterfaceOrientations, you may be mistaking something when implementing the delegate method `navigationControllerSupportedInterfaceOrientations` or setting the delegate of the navigation controller.I created a simple project with navigation controller and navigationControllerSupportedInterfaceOrientations is called multiple times. Please show your code.
Please show your code first.
`Decoder` is a protocol where all `Decodable` things rely on.You should better not implement `init(from decoder: Decoder)` using some extended feature of a specific `Decoder`.Please show more concrete examples, JSON texts of the endpoints and your model.
In this simple case as in your example, you have no need to do anything special.(Please show valid JSON texts, with easily testable code and data, more readers would test them and you would get more responses.)struct Book: Codable {
var author: String
var title: String
var libraryId: String?
var sectionNumber: String?
var length: String?
var reviews: String?
enum CodingKeys: String, CodingKey {
case author = "Author"
case title = "Title"
case libraryId = "LibraryId"
case sectionNumber = "SectionNumber"
case length = "Length"
case reviews = "Reviews"
}
}
struct Result: Codable {
var book: Book
enum CodingKeys: String, CodingKey {
case book = "Book"
}
}
let endpoint1Text = """
{
"Book": {
"Author": "James",
"Title": "JamesBook",
"LibraryId": "387fh384fh3i09",
"SectionNumber": "870D"
}
}
"""
let endpoint2Text = """
{
"Book": {
"Author": "James",
"Title": "JamesBook",
"Length": "870",
"Reviews": "9/10"
}
}
"""
do {
let result1 = try JSONDecoder().decode(Result.self, from: endpoint1Text.data(using: .utf8)!)
print(result1)
let result2 = try JSONDecoder().decode(Result.self, from: endpoint2Text.data(using: .utf8)!)
print(result2)
} catch {
print(error)
}Tested in Playgrounds, I get this.Result(book: __lldb_expr_5.Book(author: "James", title: "JamesBook", libraryId: Optional("387fh384fh3i09"), sectionNumber: Optional("870D"), length: nil, reviews: nil))Result(book: __lldb_expr_5.Book(author: "James", title: "JamesBook", libraryId: nil, sectionNumber: nil, length: Optional("870"), reviews: Optional("9/10")))Your actual model may be more complex and there may be some difficulties, but I cannot say any more without seeing it.
If the type definition does not have an explicit declaration of the initializer, Swift compiler will automatically generate it.
The line you have shown would work well if `sender` is an `NSMenuItem`, even when any other events than mouse clicks.Mouse click is definately a runtime event and I cannot see what you think difficult.You may need to clarify more things, on what sort of event do you want to toggle the check marks?
It is very welcome and helpful if you answer my question directly.on what sort of event do you want to toggle the check marks?
on what sort of event do you want to toggle the check marks?Please answer to my question directly. Or, if you have some words you do not understand, please tell me.
Currently, one of the most popular ways is using `Result` type as an argument to the completion handler: func submitPost(post: User, completion:((Result<String, Error>) -> Void)?) {
//...
let encoder = JSONEncoder()
do {
let jsonData = try encoder.encode(post)
request.httpBody = jsonData
print("jsonData: ", String(data: request.httpBody!, encoding: .utf8) ?? "no body data")
} catch {
completion?(.failure(error)) //<-
}
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let task = session.dataTask(with: request) { (responseData, response, responseError) in
guard responseError == nil else {
completion?(.failure(responseError!)) //<-
return
}
if
let data = responseData,
let utf8Representation = String(data: data, encoding: .utf8)
{
print("response: ", utf8Representation)
completion?(.success(utf8Representation)) //<-
} else {
print("no readable data received in response")
completion?(.success("no readable data received in response")) //or you may want to pass .failure with your own error
}
}
task.resume()
}You can use it like this: submitPost(post: myPost) { (result) in
switch result {
case .success(let value):
print(value)
//...use value here
case .failure(let error):
print(error)
fatalError(error.localizedDescription)
}
}
Doesn't faceanchor.transform.columns.2 contain head rotation values?No. Transformation matrix is sort of combined representation of rotation, translation and scaling.Any of the rows does not contain rotation values separately.You can find how to separate the rotation matrix from the transformation matrix, if you learn 4x4 transformation matrix theory.I do not understand what you mean by rotation values, but there may be some ways to calculate it from the transformation matrix.You would have a better chance that some ARKit experts find your your question, if you choose an appropriate topic area: ARKit
So, what do you want to ask?---Generally, if you want to make per-character based mapping on String:- `components(separatedBy:)` and `joined(separator:)` are not good tools- You need to define the output for the characters not contained in the `map`I would write it as:var text = "hello"
let map: [Character: Character] = ["0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","a":"ᴀ","b":"ʙ","c":"ᴄ","d":"ᴅ","e":"ᴇ","f":"ғ","g":"ɢ","h":"ʜ","i":"ɪ","j":"ᴊ","k":"ᴋ","l":"ʟ","m":"ᴍ","n":"ɴ","o":"ᴏ","p":"ᴘ","q":"ǫ","r":"ʀ","s":"s","t":"ᴛ","u":"ᴜ","v":"ᴠ","w":"ᴡ","x":"x","y":"ʏ","z":"ᴢ","A":"A","B":"B","C":"C","D":"D","E":"E","F":"F","G":"G","H":"H","I":"I","J":"J","K":"K","L":"L","M":"M","N":"N","O":"O","P":"P","Q":"Q","R":"R","S":"S","T":"T","U":"U","V":"V","W":"W","X":"X","Y":"Y","Z":"Z"]
let string = String(text.map {ch in map[ch, default: ch]})
print(string) //->ʜᴇʟʟᴏ
Please clarify what you want to ask.---When you show error message, better take more parts of the error info shown in the debug console:Fatal error: Index out of rangeAnd the exact line number of the errorcharArray[i] = map[charArray[i]] ?? textYour `charArray` is an Array of only one element "hello", but your `i` gets greater than 0.Thats the reason for the error Index out of range.But you have no need to (and should not) use `components(separatedBy:)`, so check my answer for you another question.
I am wondering why it saysValue of optional type 'String?' must be unwrapped to a value of type 'String'right behindThe lefthand side of your assignment expression (`charArray[i]`) is of type `String`,but the righthand side (`map[charArray[i]]`) is of type `String?` (aka `Optional<String>`).You need to unwrap an Optional value to assign it to a non-Optional.But your current code has some more flaws and you may need to fix them first.