ios – iPad not accepting Apple ID

For some time now my iPad Air 2 has been pestering me to enter my Apple ID. When I do, I get error “Verification Failed Your Apple ID or password is incorrect”. I’m currently using my MacBook with the same Apple ID without any problems.

After searching the inertnet I’ve

  • tried rebooting the device without help
  • changed my Apple ID password twice without help
  • updated to iOS 14.3, still no help

One advice is trying to sign in using another account – but the bloody thing doesn’t even allow me to sign out!!! It’s asking me to enter Apple ID password to turn off “Find My iPad”, which then subsequently fails.

I’ve tried with multiple wireless connections. Currently iPad’s associated with my phone’s hotspot with 4G connection, and Speedtest gives consistently ~85Mbps down / ~40Mbps up, so at least speed shouldn’t be an issue. According to https://www.apple.com/support/systemstatus/ all services are available.

Last thing I tried was resetting iPad’s network settings. After restarting I connected to my hotspot successfully and tried to login, which resulted in my account getting locked. I successfully unlocked it with my MacBook. However, still not able to login with my iPad.

How do I get this pesky thing working?

mobile – Swipe for Action: iOS vs Android

In iOS there is a quite common pattern for lists, which consists of swiping an item of the list for getting some possible action.
Sometimes, like in the example below even both swiping direction are supported, showing different actions.

enter image description here

As Android user I am not really familiar with this pattern, and I wouldn’t even try to swipe horizontally on a list item, cause I don’t expect any option to appear.

I was wondering though, how is this pattern translated in Android world? Which are the most common patterns in Android for getting the same functionality but in an Android-consistent way? Overflow button? long press?

ios – App crash: Fatal Exception: NSFileHandleOperationException*** -[NSConcreteFileHandle writeData:]: Invalid argument

I’m generating a local file for log file and upload it to server. But it crashes with Fatal Exception: NSFileHandleOperationException -(NSConcreteFileHandle writeData:): Invalid argument. Below is my LogFileManager class. The crash points to saveLog function, below is the stack trace

Fatal Exception: NSFileHandleOperationException
0  CoreFoundation                  0x182879344 __exceptionPreprocess
1  libobjc.A.dylib                 0x18258ecc0 objc_exception_throw
2  Foundation                      0x182c1c050 -(NSConcreteFileHandle readDataUpToLength:error:)
3  Foundation                      0x182ba7504 -(NSConcreteFileHandle writeData:)
4  MyMobileApp    0x10122dfb4 closure #1 in static LogFileManager.saveLog(logParameters:) (<compiler-generated>)
5  MyMobileApp    0x1013b64e0 thunk for @callee_guaranteed () -> () (<compiler-generated>)
6  MyMobileApp    0x1013b6500 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
7  libdispatch.dylib               0x18251b5ac _dispatch_client_callout
8  libdispatch.dylib               0x18251fa34 _dispatch_sync_function_invoke
9  MyMobileApp    0x10122db18 static LogFileManager.saveLog(logParameters:) (<compiler-generated>)
10 MyMobileApp    0x101385cd8 static LogManagerAPI.updateLog(_:url:responseStatus:response:httpMethod:parameters:httpHeaderField:) + 57 (LogManagerAPI.swift:57)
11 MyMobileApp    0x1015fe294 ServiceResponse.logResponse() + 16 (LogManager.swift:16)
12 MyMobileApp    0x1011f54e4 closure #1 in ServiceRESTAPI.callService<A>(completion:) + 189 (ServiceRequestProtocol.swift:189)
13 Alamofire                       0x106a6f4e0 (Missing)
14 Alamofire                       0x106a733c4 (Missing)
15 Alamofire                       0x106a4d6d8 (Missing)
16 libdispatch.dylib               0x18251a134 _dispatch_call_block_and_release
17 libdispatch.dylib               0x18251b5ac _dispatch_client_callout
18 libdispatch.dylib               0x1825277d4 _dispatch_main_queue_callback_4CF
19 CoreFoundation                  0x1827f48d4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
20 CoreFoundation                  0x1827ef58c __CFRunLoopRun
21 CoreFoundation                  0x1827eebc8 CFRunLoopRunSpecific
22 GraphicsServices                0x18cbd75cc GSEventRunModal
23 UIKitCore                       0x1869a1744 UIApplicationMain
24 MyMobileApp    0x10100ddb0 main + 33 (AppDelegate.swift:33)
25 libdyld.dylib                   0x18266b384 start

This is my LogFileManager class

class LogFileManager {
    
    static var logFile: URL? {
        guard let documentDirectoryURL =  try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) else {
            return nil
        }
        return documentDirectoryURL.appendingPathComponent(Constants.FileName.elkLogFile)
    }

    static func handleFileSize(filePath: String) {
        let file: FileHandle? = FileHandle(forReadingAtPath: filePath)
        file?.seek(toFileOffset: 500000)
        let databuffer = file?.readDataToEndOfFile()
        let tempURL = createLogDataFile(withData: databuffer, withFileName: "LogFile.txt")
        replaceExistingFile(withTempFile: tempURL)
        file?.closeFile()
    }
    
    static func sizePerMB(url: URL?) -> Double {
        guard let filePath = url?.path else {
            return 0.0
        }
        do {
            let attribute = try FileManager.default.attributesOfItem(atPath: filePath)
            if let size = attribute(FileAttributeKey.size) as? NSNumber {
                return size.doubleValue / (1024 * 1024)
            }
        } catch {
            print("Error getting size")
        }
        return 0.0
    }
    
    static func createLogDataFile(withData data: Data?, withFileName name: String) -> URL? {
        if let destinationURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
            let fileManager = FileManager.default
            var itemReplacementDirectoryURL: URL?
            do {
                try itemReplacementDirectoryURL = fileManager.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: destinationURL, create: true)
            } catch _ {
                print("Failed to replace file")
            }
            guard let destURL = itemReplacementDirectoryURL else {return nil}
            guard let data = data else {return nil}
            let tempFileURL = destURL.appendingPathComponent(name)
            do {
                try data.write(to: tempFileURL, options: .atomic)
                removeLogFile()
                return tempFileURL
            } catch _ {
                print("Failed to write file")
                return nil
            }
        }
        return nil
    }
    
    static func replaceExistingFile(withTempFile fileURL: URL?) {
        guard let fileURL = fileURL else {return}
        if let destPath = logFile {
            do {
                let dta = try Data(contentsOf: fileURL)
                try dta.write(to: destPath, options: .atomic)
            }
            catch _ {
                print("Failed to replace the logfile with tempfile")
            }
        }
    }
    
    static func removeLogFile() {
        let filemanager = FileManager.default
        if let logFile = logFile {
            do {
                try filemanager.removeItem(atPath: logFile.path)
            } catch _ as NSError {
                print("Failed to delete the log file")
            }
        }
    }
    
    static func saveLog(logParameters: (String: String)) {
        guard let logFile = logFile else {
            return
        }
        let log: LogModel = LogModel(logParameters)
        let encoder = JSONEncoder()
        guard var jsonData = try? encoder.encode(log) else {
            return
        }
        guard let commaAddition = ",".data(using: String.Encoding.utf8) else {
            return
        }
        jsonData.append(commaAddition)
       DispatchQueue.global(qos: .background).sync {
            if FileManager.default.fileExists(atPath: logFile.path) {
                if sizePerMB(url: logFile) >= 5 {
                    handleFileSize(filePath: logFile.path)
                }
                let fileHandle = try? FileHandle(forWritingTo: logFile)
                fileHandle?.seekToEndOfFile()
                fileHandle?.write(jsonData)
                fileHandle?.closeFile()
            } else {
                try? jsonData.write(to: logFile, options: .atomicWrite)
            }
        }
    }
}

So far, I couldn’t find a way to fix this crash. Any help is appreciated.

iphone – “Unable to load photo, an error occurred while loading a higher quality version of this photo” error message in Photos (iOS)

I’m trying to view a photo on my device but it’s incredibly low quality and has a white information button in the bottom right, which when pressed says:

“Unable to load photo, an error occurred while loading a higher quality version of this photo”

I have plenty of storage left, I’ve tried running the Photos app with low power mode off, restarting my phone etc and nothing helps.

It’s especially frustrating as I’m sure I never set it to ‘optimise storage’ and typically the one photo it’s lost is one of my absolute favourite memories and photos of my wife. Sigh.

Is there anyway I can get this back please? Thank you

Capture both audio and video from iOS device via USB in OBS

I want to record both screen and audio from iOS device using my MacBook, so I connected the device to my computer using cable. I then opened QuickTime Player, click “File -> New Movie Recording”, and select the iOS device as video and audio input from the drop down menu next to the record button, and everything works fine.

I then tried OBS as QuickTime is not very flexible. The video is available in “video capture device”, but the audio cannot be found anywhere. After a bit research, I found audio input can be enabled using “Audio MIDI Setup”. However, with OBS opened, the audio device immediately became disabled about a second after I click “Enable” in the Audio MIDI Setup. When I close the OBS (or remove the video input from the iOS device), however, the audio input in the MIDI setup works, and I can record audio in OBS via “audio input capture”.

The frustrating thing is that I cannot record both in OBS, it seems like iOS device can only operate in 1 of the 2 modes that provides either video (screen cast) or audio via USB, but not both. But how does QuickTime works? The audio input option from iOS device is in the QuickTime even when the device is not enabled in Audio MIDI Setup (and when enabled, the device is listed twice with slightly different names). This seems like QuickTime use a different mechanism to grab the audio input from iOS device, and I am not aware of any other applications can do this.

The workaround I found is to record the main speaker output (using SoundFlower or other similar tools) since QuickTime will output the audio from iOS device to main speaker of my MacBook. However, the setup is quite complicated and not very flexible (included below).

Any better ways to do this?


Appendix (how to use SoundFlower to workaround this)

  1. First connect the device via cable and open QuickTime. Go to “File -> New Audio Recording”, and select the device in the drop down menu next to record button (but don’t hit record). This will output the audio from device to main speaker.
  2. Open Audio MIDI Setup, on the lower right corner, click “+ -> Create Multi-Output Device”, add both SoundFlower and Main Speaker.
  3. Open “System Preferences -> Sound” and set the output to the device just created. You can now record the audio from SoundFlower in OBS.