Posts

Post not yet marked as solved
2 Replies
2.7k Views
I read today in the Swift book:__weak typeof(self) weakSelf = self; self.block = ^{ __strong typeof(self) strongSelf = weakSelf; [strongSelf doSomething]; } // Excerpt From: Apple Inc. “Using Swift with Cocoa and Objective-C (Swift 3.1).”When I saw '__strong' I got a bit concerned - in the past I had always used "typeof(self) strongSelf = weakSelf;, think the typeof made strongSelf strong.Yikes! Did I get it wrong all these years???
Posted
by dhoerl.
Last updated
.
Post marked as solved
7 Replies
3.2k Views
What I'd like to do is provide a CVPixelBuffer as the dataInfo argument to CGDataProviderCreateWithData that has an initializer:init?(dataInfo info: UnsafeMutableRawPointer?, data: UnsafeRawPointer, size: Int, releaseData: @escaping CGDataProviderReleaseDataCallback)My best (and probably wrong) approach to convert to a UnsafeRawPointer is:let pixelBuffer: CVPixelBuffer ... let ptr: UnsafeMutableRawPointer = UnsafeMutableRawPointer(mutating: &pixelBuffer)However, the releaseData callback function is defined as:typealias CGDataProviderReleaseDataCallback = (UnsafeMutableRawPointer?, UnsafeRawPointer, Int) -> VoidI cannot think of any way to get the CVPixelBuffer back from the UnsafeMutableRawPointer. Clearly I need help!
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
721 Views
I found that COLUMNS is no longer set, and it caused issues using vi edit mode in the shell. I found nothing in Apple's docs about environmental variables, but did find this online: https:// + ss64.com + /osx/syntax-env_vars.html which lists a slew of variables, most of which I don't see. I don't see any option in Preferences to enable or disable this. HELP!
Posted
by dhoerl.
Last updated
.
Post marked as solved
5 Replies
1.9k Views
Combine has two related functions that support "demand", where Subscribers inform Publishers on the desired number of elements passed to them in a "receive" function. The below ignores infinite demand.1) func request(_ demand: Subscribers.Demand)Subscriptions provide this function, and as the Apple Docs say:"Tells a publisher that it may send more values to the subscriber."Matt Gallagher supposes in his excellent 22 Combine Tests article that each of these demands should be additive, and when the Subscription sends elements to the Subscriber, it decrements the count.2) func receive(_ input: Self.Input) -> Subscribers.DemandWhen a Subscriber receives data, it returns another demand, which the Apple docs state is:"A Subscribers.Demand instance indicating how many more elements the subscriber expects to receive."I have seen various interpretations on how these numbers relate, and I of course have my own that I'll postulate here.---A Publisher has a one element, and it gets a 'request(.max(10))' When it sends that to the Subscriber, and the return demand should be '.max(9)', a reminder to the Publisher (actually a Subscription created by the Publisher) that its expecting 9 more elements.If for some reason the Subscriber decides to send in another request for .max(10), and the Publisher gets one more element, and messages the Subscriber with that one element, the return will then be .max(18), meaning, Subscriber wanted 10, then it wanted 10 more, but it has only received 2.Alternate interpretations seem to be that the return from receive is additive to the running total. So any number other than 0 will increase what the Publisher can send.Would be super if anyone in the know could help clarify!!!
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
387 Views
It seems since I updated to Xcode 12, when I stop at breakpoints the cursor hovering is broken. I cannot see any variable values and must add print statements. Trying "print foo" from the console also fails: "Error: cannot find 'foo' in scope" Suggestions?
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
943 Views
I'm getting occasional crashes with the following on a background thread: 0 __exceptionPreprocess + 224 1 objc_exception_throw + 52 2 _AssertAutolayoutOnAllowedThreadsOnly + 416 3 -[NSISEngine withBehaviors:performModifications:] + 28 4 -[UIView(UIConstraintBasedLayout) _resetLayoutEngineHostConstraints] + 72 5 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1948 6 -[CALayer layoutSublayers] + 280 7 CA::Layer::layout_if_needed(CA::Transaction*) + 464 8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136 9 CA::Context::commit_transaction(CA::Transaction*, double) + 292 10 CA::Transaction::commit() + 672 11 CA::Transaction::release_thread(void*) + 224 12 _pthread_tsd_cleanup + 576 13 _pthread_exit + 76 14 _pthread_wqthread_exit + 92 15 _pthread_wqthread + 412 16 start_wqthread + 4 Of course no idea what actual class was doing what. I'm trying to focus on where this could be, and it would seem "CA::Transaction::commit()" points to some kind of animation block. But, if the view uses constraint based layout, could it be anything?
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
1 Replies
459 Views
Xcode stalls at the end - first time I ever had this. So I got Transporter. My upload slowly gets to 30%, stalls, then the progress starts going down (how can that happen?). Been that way for two hours this morning (9/2/2020). Am I the only one?
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
404 Views
Using AV Foundation to take photos, and I have the age old issue now of users locking rotation in portrait, turning the device, and taking a landscape photo. StackOverflow is filled with suggestions on using the accelerometer etc to monitor device changes. Wow - that's a lot of work. Isn't there anything in iOS 13 or 14 that will return the actual device orientation? Something like: 	UIDevice.current.actualOrientation Sure would be nice! Not hopeful for an answer, but hey maybe something changed in the last few years. David
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
1 Replies
498 Views
The Apple documentation for background downloads contains this paragraph: Use Background Sessions Efficiently When the system resumes or relaunches your app, it uses a rate limiter to prevent abuse of background downloads. When your app starts a new download task while in the background, the task doesn't begin until the delay expires. The delay increases each time the system resumes or relaunches your app. As a result, if your app starts a single background download, gets resumed when the download completes, and then starts a new download, it will greatly increase the delay. Instead, use a small number of background sessions — ideally just one — and use these sessions to start many download tasks at once. This allows the system to perform multiple downloads at once, and resume your app when they have completed. My question is, if I'm using the background task for uploads, does the same rate limitation apply? David
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
1 Replies
395 Views
URLSession (background, if it matters), is configured to only allow two connections to a host. Say a dozen are created, and after each is created it's told to "resume". The first two should start immediately, since the session is allowed two, and there are 0 or 1 when the task is resumed. But how about the other 10 that were told to resume too - is the order they get scheduled in random, or deterministic? David
Posted
by dhoerl.
Last updated
.
Post marked as solved
1 Replies
560 Views
Situation: App has several huge files to upload to a server. User starts upload in foreground, get tired watching the slow progress, and backgrounds the app do web surf. I've been looking at "tus" (resumable uploads) and coming up with all kinds of crazy schemes, and sitting back and rethinking this, I'm now wondering if I have overcomplicated the solution. What appears now to be the simple and easiest solution is to create a background URL Session while in the foreground, set "isDiscretionary" to false (want uploads to start immediately), then create some upload tasks and using the session delegate, watch the progress. If the app backgrounds, then iOS will continue them with "isDiscretionary" still true (subject to internal constraints). Obviously no more progress delegate calls (no delegate!) When upload tasks finished, the system will message me. I can even add more tasks at that point if I want. If the task comes back into the foreground during the upload, I can reconstitute the session config, add myself back as a delegate and then I'll start seeing the delegate session messages again. The above may sound simple and self apparent, but really, I've read many articles on using background sessions and haven't seen the use case of initiating them in the foreground and having the app switch back and forth between foreground and background. Would really appreciate knowing if what I postulated above is correct or not. As an aside, I was going to use the "tus" Concatenation API, break the big file into chunks, start sending the chunks in foreground, if moved to the back, cancel any partial uploads, then re-submit uploads to a background task. Complex and if the above works, totally unneeded. David
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
0 Replies
319 Views
Started working on a five year old app, and iCloud backup concerns suddenly came into focus. This app creates huge image files, which appear are saved directly in the Documents folder with no apparent ExcludedFromBackup attribute (just searched the code base). 1) Benefits Suppose the iOS device with a large number of images on it gets dropped in a pail of water and dies. Then the owner buys a new device, and does a restore. I believe any files in the Document folder that are NOT excluded will now exist on any restore to a new device. This would appear to be the core benefit of letting iOS backup those images. 2) How to view? Without writing code to examine all files in the Documents folder, it would be really nice to determine what files, and their sizes, exist in iCloud for the app under question. I'll guess this just isn't possible - but asking in case there is some way, I'd love to know it (and I searched google a long time before posting this question). David PS: iCloud Drive my only option for a related Tag
Posted
by dhoerl.
Last updated
.
Post marked as solved
3 Replies
585 Views
I'm looking at using "tus" to upload large files. This protocol allows for pause and resume. My thought is to start the upload in the foreground while the app is running. But its going to take 10 minutes and the user is bored, so they background the app. At this point, the app has sent say 100M of data (using fileUpload with a normal URLSession). I have 30 seconds to get some background task going, so what I'd like to do is submit the file upload to a URL Session, and indicate (through some magic property) that I want the upload task to use a Range of data in the file, not the whole file. Is this possible? The problem is that otherwise, I have to just send the whole file, or duplicate the file more or less with the first 100M not duplicated. These are close to 1G file so prefer not to do that. Ideas most welcome!
Posted
by dhoerl.
Last updated
.
Post not yet marked as solved
1 Replies
728 Views
My company's app is using the Objective C GVRSDK framework in their app (Google). This framework is no longer supported. It has a lot of classes, and one of them links to UIWebView, meaning in December we cannot submit new versions of our app. We don't use the UIWebView.Wondering if we can just "patch" the binary somehow, and change UIWebView to XXWebView, and provide our own class for that (which does nothing) so that the linker is happy.Is this possible, and if so, any tips on how we might do it?Thanks!David
Posted
by dhoerl.
Last updated
.