I have an iOS app that allows user to select a folder (from Files). I want to bookmark that folder and later on (perhaps on a different launch of the app) access the contents of it. Is that scenario supported or not? Can't make it work for some reason (e.g. I'm getting no error from the call to create a bookmark, from a call to resolve the bookmark, the folder URL is not stale, but... startAccessingSecurityScopedResource() is returning false.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
This was mentioned in another thread 4 years ago:
This whole discussion assumes that every network connection requires a socket. This isn’t the case on most Apple platforms, which have a user-space networking stack that you can access via the Network framework [1].
[1] The one exception here is macOS, where Network framework has to run through the kernel in order to support NKEs. This is one of the reasons we’re in the process of phasing out NKE support, starting with their deprecation in the macOS 10.15 SDK.
Is macOS still an unfortunate exception that requires a socket per Network framework's connection?
is JSONSerialization.jsonObject(with: inputStream) reliable? sometimes it works fine (e.g. with small objects) and sometimes it blocks forever (easier to get the block with big objects). yet sometimes it works ok even with big objects. tried to call it on a different queue - didn't help.
i have a list like this:
id: 1, image: image1, title: title1, badge: 0
id: 2, image: image2, title: title2, badge: 0
id: 3, image: image3, title: title3, badge: 0
...
is my understanding correct that in order to do a smooth "expected" animation when I want to change both the badge of the item and its order i have to manually split this "big" update into two smaller updates (first change then move, or vice versa)?
this is somewhat surprising, i would expect a diffable implementation to have a notion of "identity" (in the example above it's "id") and calculate the differences based on that identity plus ite equivalence check rather than just based on the hash/equality check for the whole item.
hello,
i don't think it is provided by the system already so i'd like to implement a smart version of DispatchQueue.async function - the one that will not reschedule the block if i am already on the queue in question and call the block directly instead in this case.
extension DispatchQueue {
func asyncSmart(execute: @escaping () -> Void) {
if DispatchQueue.current === self { // ?????
execute()
} else {
async(execute: execute)
}
}
}
the immediate problem is that there is no way to get the current queue (in order to compare it with the queue parameter and do the logic branch).
anyone've been through it and solved this puzzle?
Why is "fork" prohibited in sandboxed apps?
Hi,
Given pthread_id (†), is there a way to find the associated NSThread (when the one exists)? Perhaps using an undocumented / unsupported method – I don't mind.
Thank you!
(†) the pthread_id is neither of the current nor of the main thread.
hello,
how do i create a virtual microphone on macOS that can be selected as a default input device in System Settings or in apps like FaceTime / QuickTime Player / Skype, etc?
is Audio HAL plugin the way to go?
i've seen this macOS 10.15 note: "Legacy Core Audio HAL audio hardware plug-ins are no longer supported. Use Audio Server plug-ins for audio drivers." though i am not sure if that's applicable, as i can think of these interpretations:
1 "Legacy Core Audio HAL audio hardware plug-ins are no longer supported (but you can still use non-legacy ones.)
2 "Legacy Core Audio HAL audio hardware plug-ins are no longer supported." (but you can still use non-hardware ones".)
3 "Legacy Core Audio HAL audio hardware plug-ins are no longer supported". (if you used that functionality to implement audio hardware drivers then your you can use Audio Server plug-ins instead, otherwise you are screwed.)
The "Audio Server plugin" documentation is minimalistic:
https://developer.apple.com/library/archive/qa/qa1811/_index.html
which leads to a 2013 sample code:
https://developer.apple.com/library/archive/samplecode/AudioDriverExamples/Introduction/Intro.html
and contains a "nullAudio" plugin and a kernel extension backed plugin - neither of those i wasn't able to resurrect (i'm on macOS Catalina now).
any hints?
Am I calling this right?
host_priv_t hostPriv = 0;
int err = host_get_host_priv_port(mach_host_self(), &hostPriv);
err = host_processors(hostPriv, &processorList, &processorCount);
host_get_host_priv_port above returns 4 "(os/kern) invalid argument".
Tried with App Sandbox enabled and disabled.
I'm trying to reproduce a case when there are more dispatch queues than there are threads serving them. Is that a possible scenario?
The man page for getifaddrs states:
The ifa_data field references address family specific data. For AF_LINK addresses it
contains a pointer to the struct if_data (as defined in include file <net/if.h>) which
contains various interface attributes and statistics. For all other address families, it
contains a pointer to the struct ifa_data (as defined in include file <net/if.h>) which
contains per-address interface statistics.
I assume that "AF_LINK address" is the one that has AF_LINK in the p.ifa_addr.sa_family field.
However I do not see "struct ifa_data" anywehere. Is this a documentation bug and if so how do I read this documentation right?
I have an iOS app that allows user to select a folder (from local Files).
User is seemingly capable selecting the "On My iPhone" folder (the "Open" button is enabled, clickable and when it is tapped the app gets the relevant URL) although there's nothing in that folder apart from ".trash" item. Is selecting that folder not supported? If not why is the "Open" button enabled on that level to begin with?
is this a bug that NSDateFormatter knows about leap days but not about leap seconds?
let f = DateFormatter()
f.timeZone = TimeZone(identifier: "UTC")
f.dateFormat = "yyyy/MM/dd HH:mm:ss"
// last leap year
let t1 = f.date(from: "2020/02/29 00:00:00") // 2020-02-29 00:00:00 UTC
// last leap second
let t2 = f.date(from: "2016/12/31 23:59:60") // nil
https://developer.apple.com/documentation/foundation/urlcache
has this:
"Although URLCache instance methods can safely be called from multiple execution contexts at the same time, be aware that methods like cachedResponse(for:) and storeCachedResponse(_:for:) have an unavoidable race condition when attempting to read or write responses for the same request."
What does it mean "unavoidable"? If I put a lock (mutex / NSLock, or similar) in my wrappers on top of "cachedResponse" / "storeCachedResponse" would that avoid the mentioned race condition?
Also, what do they mean by "the same request"? A few examples below:
let url = URL(string: "https://www.apple.com")!
let req1 = URLRequest(url: url)
let req2 = req1 // perhaps "the same"
let req3 = URLRequest(url: url) // "the same"?
let req4 = URLRequest(url: req1.url!) // "the same"?
let req5 = URLRequest(url: url, cachePolicy: req1.cachePolicy, timeoutInterval: req1.timeoutInterval) // "the same"?
let req6 = URLRequest(url: url, cachePolicy: req1.cachePolicy, timeoutInterval: 1234) // "the same"?
let req7 = URLRequest(url: url, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: req1.timeoutInterval) // "the same"?
assert(req1 == req2)
assert(req1 == req3)
assert(req1 == req4)
assert(req1 == req5)
assert(req1 == req6) // this is ok
assert(req1 == req7) // this fails
Given an arbitrary memory address how do I find (in runtime) the nature of memory block it belongs to?
For stack addresses I guess there's some "stack start" and "stack end" of the current thread. For other threads' stacks - I guess I'd have to enumerate all threads to get those ranges. I also found that I can use malloc_size and sometimes it gives me correct result (the size if non zero at least), although it doesn't give me the beginning of the block memory address belongs to. For anything else I have no clue at the moment.
Ideal method I am looking for:
struct MemoryBlock {
let type: MemoryBlockType // stack, heap, unmapped, etc
let start: UnsafeRawPointer
let size: Int
let attributes // e.g. red / write
}
func findMemoryBlock(_ address: UnsafeRawPointer) -> MemoryBlock
PS. the language doesn't matter (e.g. can be C) so long as this method works in a swift/obj-c app.