Is Combine replacing NotificationCenter and Key-Value Observing?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Say that in this example here, the struct
struct Reminder: Identifiable {
var id: String = UUID().uuidString
var title: String
var dueDate: Date
var notes: String? = nil
var isComplete: Bool = false
var city: String
}
is modified slightly to include a city string. In the collection view that displays the reminders, I'd like each section to be each unique city, so if two reminder cells have the same city string then they would be in the same section of the collection view.
The progress I've made to this end is sorting the reminders array so that reminders cells are grouped together by city
func updateSnapshot(reloading ids: [Reminder.ID] = []) {
var snapshot = Snapshot()
snapshot.appendSections([0])
let reminders = reminders.sorted { $0.city }
snapshot.appendItems(reminders.map { $0.id })
if !ids.isEmpty {
snapshot.reloadItems(ids)
}
dataSource.apply(snapshot)
}
Where I'm stuck is in coming up with a way to make the snapshot represent sections by unique cities, and not just one flat section of all reminders.
Apple's Displaying Cell Info tutorial shows using a default cell content configuration to set two lines of text
func cellRegistrationHandler(cell: UICollectionViewListCell, indexPath: IndexPath, id: String) {
let reminder = Reminder.sampleData[indexPath.item]
var contentConfiguration = cell.defaultContentConfiguration()
contentConfiguration.text = reminder.title
contentConfiguration.secondaryText = reminder.dueDate.dayAndTimeText
contentConfiguration.secondaryTextProperties.font = UIFont.preferredFont(forTextStyle: .caption1)
cell.contentConfiguration = contentConfiguration
}
How would I get started extending this to include a third line of text? I would like to keep the built-in text, secondaryText, and accessory control (the tutorial has a done button on each cell), while also adding custom UI elements. I'm assuming this is possible since Apple uses the term "compositional collection views," but I'm not sure how to accomplish this. Is it possible, or would I instead need to register a custom UICollectionViewCell subclass?
Does Apple have Xcode Cloud sample code, or any sample code that contains tests?
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
Xcode
Continuous Integration
Xcode Cloud
wwdc2022-110361
I'm debugging an issue where the device unexpectedly turns to landscape and back to portrait orientation, and trying to find the root cause of it.
My company has all iOS commit pushes broadcast build failures in Slack, and I'd rather not dump a bunch of these there while I work to resolve Xcode Cloud build failures unique to its temporary build environment.
I can only select a tab bar button item. Then, CPU usage spikes to 100%-200% and I can no longer do anything like tapping a cell or scrolling. Any thoughts on the potential cause, fix, or a workaround? This happens with both devices and simulators.
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return [.landscapeRight, .landscapeLeft]
}
My modal view controller overrides this property, as its a complex custom video player that needs to be restricted to landscape. However, when it's dismissed, there is a jarring bug in the transition where the presenting VC is portrait in the device's landscape state for a second while half of the screen is black. It returns to normal (portrait) after a second, but I would like to avoid this transition bug.
What might I be missing as to the root cause, or recommended way to have a portrait app (set in project navigator) present a landscape-only view controller?
I encountered this error
2023-01-24T22:14:41.500565325Z Installing ri documentation for cocoapods-catalyst-support-0.2.1
2023-01-24T22:14:41.500827390Z Done installing documentation for colored2, concurrent-ruby, i18n, tzinfo, zeitwerk, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, public_suffix, addressable, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-trunk, cocoapods-try, molinillo, atomos, nanaimo, rexml, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods, cocoapods-catalyst-support after 50 seconds
2023-01-24T22:14:41.500997230Z 35 gems installed
2023-01-24T22:14:42.023353910Z [in /Volumes/workspace/repository]
2023-01-24T22:14:42.023798292Z
2023-01-24T22:14:42.024448317Z [!] Invalid `Podfile` file: cannot load such file -- cocoapods-catalyst-support.
2023-01-24T22:14:42.024714192Z
2023-01-24T22:14:42.024976712Z # from /Volumes/workspace/repository/Podfile:1
2023-01-24T22:14:42.025200239Z # -------------------------------------------
2023-01-24T22:14:42.025463448Z > require 'cocoapods-catalyst-support'
2023-01-24T22:14:42.025663811Z #
2023-01-24T22:14:42.025900158Z # -------------------------------------------
from my post-clone script, which is
#!/bin/sh
# ci_post_clone.sh
export GEM_HOME="$HOME/.gem"
gem install bundler
brew install cocoapods
gem install cocoapods-catalyst-support
# Install dependencies managed with CocoaPods.
pod install
For previous iOS versions, what would be a good approach to this?
What is the recommended way to assign an optional Swift property a decoded primitive with `NSCoder`?
For an example like:
someOptionalDouble = aDecoder.decodeDouble(forKey: "SomeKey")
I'm not sure how to avoid a crash if the double was encoded as nil, while also avoiding Apple's console warning that decoding primitives as an object will become an error in the future.
I have a watchOS app (not independent) that I'm trying to bring StoreKit support to purchasing subscriptions. When I make my existing StoreKit manager for iOS target watchOS, the productsRequest(_:didReceive:) delegate callback returns an empty response.products array but I don't understand why.
One guess as to the cause is that when I initialize the SKProductsRequest, the products identifiers I pass ones with prepended bundle identifiers, which may different between iOS and watchOS? The existing iOS code has the format
static let subscriptionKindOne = Bundle.main.bundleIdentifier!.lowercased() + ".subscriptionKindOne"
static let subscriptionKindTwo = Bundle.main.bundleIdentifier!.lowercased() + ".subscriptionKindTwo"
static let subscriptionKindThree = Bundle.main.bundleIdentifier!.lowercased() + ".subscriptionKindThree"
Is this right? If so, what would be the correct way to start a products request on watchOS, so that the SKProductsResponse products array is populated?
After adding a native Mac target (SwiftUI Multiplatform + AppKit) to an iOS app, I get this compiler error. Does this require moving off of XIBs entirely, or is there something else I can do to resolve this error?
In a new document-based UIKit app, specifying in the Info.plist an import type identifier of public.log that conforms to public.content, public.data, public.item accomplishes this.
In a new document-based SwiftUI multi-platform app, doing the same crashed at the DocumentGroup initializer with the error
_SwiftData_SwiftUI/Documents.swift:91: Fatal error: The document type is public.log which does not conform to com.apple.package.
This initializer expects the document type to be a package.
After adopting sidebar / split view controller support in Mac Catalyst, there are several UI side effects that make the default title bar stick out and look inconsistent. If I hide the title bar however,
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
#if targetEnvironment(macCatalyst)
if let titlebar = windowScene.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
#endif
}
the ability to double click the top of the window to maximize it is lost. What would be the simplest approach to have both the hidden appearance, but keep the double click behavior?