Post

Replies

Boosts

Views

Activity

Reply to Crash Fatal Exception: NSInternalInconsistencyException UITableView dataSource is not set
That would help to show the code and how you defined the datasource for the tableView. That should be done: either because the class is defined as UITableViewController or because you defined the dataSource delegate in Interface Builder or with a declaration in the viewDidLoad of the controller myTable.datasource = self In this case, you need to have the ViewController to conform to UITableViewDataSource, UITableViewDelegate
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’21
Reply to Closure definition mismatch
I tested in 12.4 (Swift 5.2), and got error in             let status = wrappedKey.withUnsafeMutableBytes { (wrappedKeyBytes: UnsafeMutablePointer) in Generic parameter 'Pointee' could not be inferred Does this really compile with 5.2 for you ? Note: code would be more readable with better formatting: private static func ccAESKeyWrap(rawKey: Data, keyEncryptionKey: Data) - (data: Data?, status: Int32) { let alg = CCWrappingAlgorithm(kCCWRAPAES) var wrappedKeyLength: size_t = CCSymmetricWrappedSize(alg, rawKey.count) var wrappedKey = Data(count: wrappedKeyLength) let status = wrappedKey.withUnsafeMutableBytes { (wrappedKeyBytes: UnsafeMutablePointer) in rawKey.withUnsafeBytes { (rawKeyBytes: UnsafePointer) in keyEncryptionKey.withUnsafeBytes { (keyEncryptionKeyBytes: UnsafePointer) - Int32 in guard let wrappedKeyBytes = wrappedKeyBytes.bindMemory(to: UInt8.self).baseAddress, let rawKeyBytes = rawKeyBytes.bindMemory(to: UInt8.self).baseAddress, let keyEncryptionKeyBytes = keyEncryptionKeyBytes.bindMemory(to: UInt8.self).baseAddress else { return Int32(kCCMemoryFailure) } return CCSymmetricKeyWrap( alg, CCrfc3394_iv, CCrfc3394_ivLen, keyEncryptionKeyBytes, keyEncryptionKey.count, rawKeyBytes, rawKey.count, wrappedKeyBytes, &wrappedKeyLength) } } } guard status == kCCSuccess else { return (nil, status) } wrappedKey.removeSubrange(wrappedKeyLength..wrappedKey.count) return (wrappedKey, status) } In Swift 5 (CryptoKit), there is an withUnsafeBytes, whose signature is: func withUnsafeBytesR( body: (UnsafeRawBufferPointer) throws - R) rethrows- R In Swift 4 and Swift 5 (Foundation), there is a func whose signature is: func withUnsafeBytesResultType, ContentType( body: (UnsafePointerContentType) throws - ResultType) rethrows - ResultType But not the CryptoKit one apparently.
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’21