Post

Replies

Boosts

Views

Activity

A clean way of checking an assetWriterInput for readiness
The autor of Creating a Movie with an Image and Audio on iOS proposes the way of rechecking for assetwriter readiness. // lines 52-55 while !adaptor.assetWriterInput.isReadyForMoreMediaData { usleep(10) } adaptor.append(buffer, withPresentationTime: startFrameTime) Is this the canonical way of querying AVFoundation's objects, or maybe there's a better way than sleep and try again loop? The only remotely related post I found is How to check if AvAssetWriter has finished writing the last frame, and has four years and no answer.
1
0
564
Nov ’22
Easy access to files saved inside documentDirectory
In Swift Playgrounds on macOS, when we create a new file in .documentDirectory given by FileManager, we can always search for the results in e.g. ~/Library/Developer/Xcode/DerivedData/[project-specific]/Build/Products/Debug . I guess this location may change anytime. I know that Xcode is not Matlab, but is there a folder / a shortcut / any place in the IDE that includes the resulting files, or even presents a live preview of created files (.csv) for easy inspection?
1
0
637
Nov ’22
For OSStatus, how to get a string explaining its meaning?
SecCopyErrorMessageString returns a string explaining the meaning of a security result code and its declaration is func SecCopyErrorMessageString( _ status: OSStatus, _ reserved: UnsafeMutableRawPointer? ) -> CFString? with typealias OSStatus = Int32 Having arbitrary OSStatus (for example for kAudioFormatUnsupportedDataFormatError it is 1718449215), is there something to get the description as string? The idea would be analogous to: let x: Int32 = 1718449215 if let errMsg = SecCopyErrorMessageString(x, nil) as? String{     print(errMsg) } This is not a security result code, and the output is just OSStatus 1718449215, what I expect is a "string explaining the meaning".
1
0
4.3k
Dec ’22
Optimising initialisation of big arrays with random data
I will be filling audio and video buffers with randomly distributed data for each frame in real time. Initializing these arrays with Floats inside basic for loop somehow seems naive. Are there any optimised methods for this task in iOS libraries? I was looking for data-science oriented framework from Apple, did not found one, but maybe Accelerate, Metal, or CoreML are good candidates to research? Is my thinking correct, and if so, can you guide me?
1
0
1.4k
Dec ’22
Background uploads with short-lived authorisation tokens.
Let’s say I have a hundred of big files to upload to a server, using requests with a short-lived authorisation token. NSURLSession background upload describes a problem with adding too many requests, so the first question is: should we manage uploads manually, by which I mean queuing, postponing, retrying. Will we then fall into the same traps only in a different way? What to do if tasks picked by the system have outdated token, and so fail. How to update a token: is there a delegate method (preferable pre iOS 13 compatibile) in which I can get a fresh token and modify a request header? Is there any iOS specific design pattern or contract (Apple's list of server requirements) that would allow uploads to be resumable?
1
0
1.3k
Dec ’22
Why repeating protocol conformance in a subclass is considered redundant?
Repeating protocol conformance in a subclass of conforming class results in a redundancy error. My problem is that, because of how protocol witness tables work, repeating protocol conformance in a subclass seems not to be redundant at all . Intuitively, in the Example3 below repeating a conformance of the parent class in the child class could restore the route from protocol extension's implementation back to child's implementation . Where am I wrong? protocol Prot { func f() func g() } extension Prot { func f(){ print("protocol extension's implementation") } func g(){ f() } } class Parent: Prot { } //Directly implementing protocol would route to a child's implementation. class Example1: Prot { func f(){ print("child's implementation")} } //Indirectly implementing protocol would route to a protocol extension's implementation. class Example2: Parent { func f(){ print("child's implementation")} } //Redundant conformance of 'Child' to protocol 'Prot' error, instead of restoring route to a child's implementation. class Example3: Parent, Prot { func f(){ print("child's implementation")} } Example1().g() Example2().g()
5
0
1.9k
Dec ’22