Post

Replies

Boosts

Views

Activity

Reply to Read binary file in swift
Hi, Managed to read a char... :-) // char var ch : UInt8 = 0 var data = fileHandle?.readData(ofLength: MemoryLayout.size(ofValue:ch)) data?.copyBytes(to: &ch, count: MemoryLayout.size(ofValue:ch)) var id = Character(UnicodeScalar(ch)) But this is no-go...	:-( // UInt16 var num : UInt16 = 0 data = fileHandle?.readData(ofLength: MemoryLayout.size(ofValue:UInt16())) data?.copyBytes(to: &num, count: MemoryLayout.size(ofValue:num)) Cannot convert value of type 'UnsafeMutablePointer<UInt16>' to expected argument type 'UnsafeMutablePointer<UInt8>' Paul
Jul ’20
Reply to Read binary file in swift
Hi Quinn, The data is too big to read all into memory. I usually read my header which shows version and store offsets 'UInt64' to the data in the file (as 'pages') then close the file. When required, open the file again and jump to the data required as per the offsets read earlier. I really need to easily read chars, and ints of various sizes and big chunks as they may be png or mp3s. The char is read then a switch statement is used to read the data 'defined' by the char. The data is 'trusted?' as I wrote another app, on Windows Csharp, to create and assemble it, everything (png, mp3 etc) is created my me - it's educational software for high schools for Windows and Mac. I'm trying to convert my Objective-C app to Swift after converting my Windows version from Cplusplus to Csharp. (I'm worried that Microsoft will kill Cplusplus so went to Csharp and now worried that Apple will kill Objective-C so thinking of going to Swift. Or maybe I should just retire and go to the beach?) Thanks for your help. Paul
Jul ’20
Reply to AVCaptureDevice requestAccessForMediaType
Hi,MacOS 10.15.2<key>NSMicrophoneUsageDescription</key> <string>Record audio!</string>This works in a swift project:AVCaptureDevice.requestAccess(for: .audio) { granted in if granted { //self.setupCaptureSession() } }This doesn't work in an ObjectiveC project: (Thread 6: signal SIGABRT)[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) { if (granted) { // [self setupCaptureSession]; } }];What am I not doing correcty or forgot to include?Thanks, paul
Jan ’20