I wrote as follows.
An error occurred on line 14 because of forced unwrapping.
extension SignInViewController: ASAuthorizationControllerDelegate {
@available(iOS 13.0, *)
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
var name: String? = nil
if let appleIDCredential = authorization.credential as?
ASAuthorizationAppleIDCredential {
if let fname = appleIDCredential.fullName?.familyName { name = fname }
if let gname = appleIDCredential.fullName?.givenName {name = name == nil ? gname : name!+gname}
authenticateWithApple(token:
appleIDCredential.identityToken?.toString, code: appleIDCredential.authorizationCode?.toString, name: name)
}
}
func authenticateWithApple(token: String?, code: String?, name: String?) {
authenticationScenario.signOut(from: .apple)
let param = [LQAAccountAppleTokenKey:token!, LQAAccountAppleAuthorizationCode:code!]
...
}
}
I fixed it by rewriting as below, but I would like to know why nil is included in identityToken or authorizationCode.
guard let identityToken = appleIDCredential.identityToken, let idTokenString = String(data: identityToken, encoding: .utf8) else { return }
guard let authorizationCode = appleIDCredential.authorizationCode, let authCodeString = String(data: authorizationCode, encoding: .utf8) else { return }
Post
Replies
Boosts
Views
Activity
private func setupCollectionView() {
let registration = UICollectionView.CellRegistrationUICollectionViewListCell, Article { cell, _, item in
var content = cell.defaultContentConfiguration()
content.text = "title"
cell.contentConfiguration = content
}
XCTAssertEqual(cell.contentConfiguration.text, "title")
but
Value of type 'UIContentConfiguration?' has no member 'text'
Why does 'UIContentConfiguration?' have no member 'text' ??
Failed to parse font key token
is displayed at console.
It doesn't particularly cause crashes, UI bugs, etc., but it is a concern.
This is occurred when I zoom on SwiftUI Map.
Part of code
struct MapView: View {
var body: some View {
Map(coordinateRegion: $viewModel.region,
showsUserLocation: true,
annotationItems: viewModel.pins,
annotationContent: { item in
MapAnnotation(coordinate: item.coordinate, anchorPoint: CGPoint(x: 0.5, y: 0.5), content: {
pinButton(pin: item)
})
})
.ignoresSafeArea()
}
}
My project is here.