iosdev| aplus.rs
After upgrading all my active projects to Swift 6 language mode, I was bound to encounter some head-scratching edge cases. One of the weirdest ones was this runtime crash: Thread 5 Queue : com.apple.root.default-qos (concurrent) #0 0x00000001021243f8 in _dispatch_assert_queue_fail () #1 0x0000000102124384 in dispatch_assert_queue () #2 0x00000002444c63e0 in swift_task_isCurrentExecutorImpl () #3 0x0000000105a895b4 in closure #1 in AppDelegate.setupObjCFramework(using:flowIdentifier:) () It do...| A+ programming moments
Apple has great API for this purpose: URLSessionUploadTask. Almost at the very top, Apple says: Unlike data tasks, you can use upload tasks to upload content in the background. This is not by accident. File uploads are the least-loved feature of any app as no one wants to wait nor look at progress bars. Thus the proper way to do this is to encapsulate upload functionality into a module which is somewhat independent from the rest of the app and maintain an ability to be informed how far along ...| A+ programming moments
I don’t think I wrote many apps in the last 10 years that did not involve Core Data. Apps without Core Data: have just a handful of screens with no shared data between them are demonstration / help type of app, basically a glorified user manual But if app has any kind of model graph / data shared across multiple views, I choose Core Data without hesitation. Its strengths are in handling of relationships, its transparently cached and batched data fetching, seamless notification on insert/upd...| A+ programming moments
Let’s say you are writing an iOS client for Spotify’s API, specifically the search endpoint. Here you can get multiple entities, like Artist, Album, Track, Playlist and all of them are inter-related in that same JSON. You might get particular artist instance as top-level result and/or inside album.artists or even inside track.album.artists. It’s quite possible that one same artist can appear in all of those places. When searching repeatedly for various terms and parsing/importing each r...| A+ programming moments
Imagine a simple sports app model: League entity, with some id, name and displayOrder properties. It has a 1-many relationship to Event entity that has (among other attributes) id, name and of course — reverse to-one relationship back to League. You write a simple FetchRequest for FetchedResultsController when you are loading events grouped per league, with order defined by League.displayOrder but the section name (title) is League.name. To get the grouping with proper section titles, your ...| A+ programming moments
When designing Core Data object graph, I spend copious amount of time thinking through each entity’s attributes and relationships. If I’m not careful, I can easily end-up with expansive graph containing many one-of leaf nodes. Analysing various graphs in the past, I noticed that many complex entities (even with dozen or so attributes) are really just a complex property of their 1-1 relationship pair. Say you have some Event object that has an elaborate set of configuration options. That c...| A+ programming moments
UILabel has ability to render rather complex text through .attributtedText but is not user-interactive by default. Thus even though particular text can contain URLs or phone numbers, there is no native capability to tap on said URL and open a web view. Curiously, most open-source components that aim to enable this are years-old, written in Objective-C. Here’s how you can re-implement this feature today. First, we need an extension over String which will detect all the CheckingTypes we care ...| A+ programming moments
Last several weeks, we (Radiant Tap) are working on a major app redesign for one of our clients. App is super-data-intensive, combining multiple different data sources into one complex bi-directional scrollable view. Here’s some samples of the design: Important bits what’s in there: First section is the horizontally scrollable set of ads, which are fetched from JSON file. Rarely changes but it can. All the other sections are using data from Core Data store where some of them change very o...| A+ programming moments
OptionSet is great tool of the Swift language. It’s fantastic for modelling multi-option values like: blog tags, various kinds of flags and markers etc. Here’s a typical (for me) use case: customise cell design where content can have label and icon, might have a badge, maybe disclosure indicator, some kind of background view with or without shadow etc. You can either create a separate UICVCell subclass for each combo or do them all at once and then supply a value with enabled options: str...| A+ programming moments
Leonardo Maia Pugliese recently published a blog post that picked my interest: Coordinators and Tab Bars: A Love Story. I always love to read how other people employ this useful pattern thus I carefully read through it. The problem he is solving is this: Imagine that you have a tab bar with two tabs and each tab is a navigation controller. The Home Tab has 2 levels deep and the Orders Tab has 3 levels deep. The problem is to navigate from the second level deep view controller of home Tab to t...| A+ programming moments
Two years ago I lamented the gaping hole in the Apple’s desktop Mac lineup. I ended that post with: I would be perfectly happy to pay $3,000+ for a machine with that [16-ish core] CPU housed in Apple-designed case and cooling. If only Apple offered it. Few days ago, Apple released exactly what I asked for: Mac Studio is a very powerful workstation in 3.6L case. CPU can have up 10 (M1 Max) or 20 (M1 Ultra) cores paired with impressive GPU. It’s unreal how much power they packed into such a...| A+ programming moments
I wrote about my Essentials snippers 4 years ago. I am still using them, slightly updated and modernised but they are still one of the first stops to choose what I need when I start a particular UIKit project. One advanced feature in there is AsyncOperation which a subclass of Operation which will not set itself to finished until the asynchronous task you give it is done. OperationQueue and Operation were a staple of my code for a very long time, whenever I needed to be sure things are being ...| A+ programming moments
In the AMD Hackintosh land, successfully configuring your build to perform sleep / wake is one of the “Holly shit! It works!” moments. Even though Intel and AMD CPUs are largely compatible (with few very notable differences), their corresponding chipsets are different story. Until recently, Apple exclusively used Intel CPUs and their chipsets (to some degree). Thus it’s not surprising that OpenCore builds feature sleep / wake pretty much out of the box if you use the identical component...| A+ programming moments
Radar or GTFO! That’s an old joke in Apple developer circles which was meant to be cute but…really wasn’t. It was often remarked you shouldn’t be speaking to Apple developers about some bug if you don’t already have the bug report number at hand. You could still approach them, of course; it would usually end with some nodding on their part with advice to file a radar and let them know. Back when Apple was still an underdog, it was even some point of pride to publish your RDAR number...| A+ programming moments
Ever since I first got my MacBook Pro in 2006, I have always upgraded macOS versions. Even when switching from one MBP to another. Few times I wanted to start fresh and each time I was too lazy to do it. Getting a desktop machine was finally a good enough incentive. Essentials These are essential in a sense: “needed to setup other software” 1Password keeps all logins, important notes and software licenses. NextDNS stops adware, malware, trackers and other bullshit of the modern online wor...| A+ programming moments
As I wrote previously, I planned to buy iMac 27in whenever Apple refreshed it. They did and the config that worked for me is the base 27in model with 8-core CPU and 1TB SSD (I planned to upgrade memory myself). That configuration is ~€3.200 in Europe but here in Serbia it turned out to be ~€3.800. Mac prices were always much higher here but this one particularly irked me. I investigated the possibility of building it myself then, using the 10th-gen Intel CPUs for maximum compatibility. Fe...| A+ programming moments
Much have been spoken and written about the Hey app’s (temporary) rejection from the App Store. As predicted and expected, the high public profile of this particularDavid has forced the Goliath to yield a significant ground. There are manywayless known Davids which have the same or worse issues with the App Review capriciousness and ever-changing guidelines. I have skin in this game. Counting my own apps and client projects, I have participated in development and publishing of over 90 apps ...| A+ programming moments
hardware| aplus.rs