Posts

Post not yet marked as solved
1 Replies
1.2k Views
I'm trying to implement WidgetKit on my watchOS 9.1 app. When I'm editing the watch face, I see the widget looking as I would expect it to be. However, when I then go to the Home Screen, the data is redacted. What's causing that to happen? I don't do anything luminance or security related in the widget's view: struct AccessoryRectangularView: View {   let tide: Tide      var body: some View {     HStack {       VStack(alignment: .leading) {         Text("Height: \(tide.heightString())")           .font(.headline)           .widgetAccentable()         Text("As of: \(tide.date, style: .time)")           .font(.caption)       }              tide.image()     }   } }
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
5 Replies
2.7k Views
In Apple's documentation it says this:"This method, though convenient, is inefficient if used multiple times in succession. Achieve better performance by chaining filters without asking for the outputs of individual filters."That confuses me though because I don't know how to link them together without getting the output. For example, this is my method to apply a TiltShift filter, based on the instructions from Apple's docs. When I perform the gradient filter, I have to take the outputImage of that to pass into the next filter. What's the right way to be doing this? override public var outputImage: CIImage? { guard let inputImage = inputImage else { return nil } let clamped = inputImage.clampedToExtent() let blurredImage = clamped.applyingGaussianBlur(sigma: inputRadius) var gradientParameters = [ "inputPoint0": CIVector(x: 0, y: 0.75 * inputImage.extent.height), "inputColor0": CIColor(red: 0, green: 1, blue: 0, alpha: 1), "inputPoint1": CIVector(x: 0, y: 0.5 * inputImage.extent.height), "inputColor1": CIColor(red: 0, green: 1, blue: 0, alpha: 0) ]; guard let gradientImage = ciImage(from: "CILinearGradient", parameters: gradientParameters) else { return nil } gradientParameters["inputPoint0"] = CIVector(x: 0, y: 0.25 * inputImage.extent.height) guard let backgroundGradientImage = ciImage(from: "CILinearGradient", parameters: gradientParameters) else { return nil } let maskParameters = [ kCIInputImageKey: gradientImage, kCIInputBackgroundImageKey: backgroundGradientImage ] guard let maskImage = ciImage(from: "CIAdditionCompositing", parameters: maskParameters) else { return nil } let combinedParameters = [ kCIInputImageKey: blurredImage, kCIInputBackgroundImageKey: clamped, kCIInputMaskImageKey: maskImage ] return ciImage(from: "CIBlendWithMask", parameters: combinedParameters) } private func ciImage(from filterName: String, parameters: [String: Any]) -> CIImage? { guard let filtered = CIFilter(name: filterName, parameters: parameters) else { return nil } return filtered.outputImage }
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
510 Views
I see that if I go to the CloudKit web services pages that they're in an archived area. I've got (really old) PHP code that processes data and then uploads it to a public container. Should I be changing to something different?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
7 Replies
5.8k Views
When I try to re-open the storyboard I was just editing in the current production version of Xcode it says"The document Main.storyboard could not be opened. The operation couldn't be completed. (com.apple.InterfaceBuilder error -1)"What in the world do I do to fix that? I *really* don't want to go back to my last git commit for that file because there have been quite extensive changes with pretty complex autolayout settings.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
3 Replies
1.9k Views
I'm trying to have a navigation link that is triggered programatically. If I use the following code, on iOS, then the second NavigationLink is not put into the UI, as expected. On watchOS, however, there's a visible button with no text. How can I accomplish this on watchOS? var body: some View {   NavigationView {     VStack {       NavigationLink("No login required", destination: UnprotectedView())       NavigationLink(destination: ProtectedView(), isActive: $isActive) {         EmptyView()       }       Button("Login required", action: pushIfAuthenticated)     }     .navigationBarTitle("Choose")   } }
Posted
by Gargoyle.
Last updated
.
Post marked as solved
2 Replies
3.0k Views
I'm trying to write a method to take a string and break it up into an array where each element of the array is the next 10 characters. So a string that's 32 characters long would end up with 3 array elements containing the first 30 characters, and then the 4th array element would have the last 2 characters. I was trying to use substringWithRange for this but as soon as I advance past the str.endIndex it throws an exception, and I can't figure out how to work around that. I know it's just a silly syntax thing, but I'm stuck.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
790 Views
My standalone watchOS app is trying to read from the calendar via EventKit. It seems to only see local calendars though, not any of my iCloud calendars. Do I have to do something special to be able to view the iCloud based calendars?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
2 Replies
5.2k Views
I'm trying to wrap my head around Combine still, and so in my class that handles web requests I've written this method:static func downloadNumbersPublisher(datesByType: [LottoType: (start: Date, end: Date)]) -> URLSession.DataTaskPublisher { guard let url = downloadUrl(using: datesByType) else { return } var request = URLRequest(url: url) request.addValue("gzip", forHTTPHeaderField: "Accept-Encoding") let session = URLSession(configuration: .ephemeral) return session.dataTaskPublisher(for: request) }What I'm not clear on though is what I actually return on line 2, the guard statement.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
644 Views
In the WWDC2020 "Keep your complications up to date" session, Mike shows that you have to create an App ID that ends with ".watchkitapp.complication" in order to support PushKit. Any time I try to add ".complication" to the end of my App ID, it gives an error: An App ID with Identifier 'com.x.y.watchkitapp.complication' is not available. Please enter a different string.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
634 Views
On my watch only app I added capabilities for Push Notifications and Background remote notifications. Then, in the App I created an instance of my provider. I see the initializer being called, but the delegate methods are never called, so I have no device token. What am I missing? import Foundation import PushKit import ClockKit final class PushNotificationProvider: NSObject {   let registry = PKPushRegistry(queue: .main)   override init() {     super.init()     registry.delegate = self     registry.desiredPushTypes = [.complication]   } } extension PushNotificationProvider: PKPushRegistryDelegate {   func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {     let token = pushCredentials.token.reduce("") { $0 + String(format: "%02x", $1) }     print(token)   }   func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) async {     // Called on the main queue based on the PKPushRegistry queue parameter.     let server = CLKComplicationServer.sharedInstance()     server.activeComplications?.forEach {       server.reloadTimeline(for: $0)     }   } }
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
1.4k Views
Apple's docs show using NSString.localizedUserNotificationString for local push notifications in Swift. Why not just use the normal NSLocalizedString() methods? Is there something special about the former method?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
675 Views
I'm trying to understand the background URL download from the "Keep Your Complications Up To Date" video. I'm confused as to what the refresh method does. In his example, all it does is stores a completion handler. If schedule(first:) is what actually schedules/runs the file download, why not just pass/store the completion handler there? Seems like my applicationDidFinishLaunching method would call schedule(first: true)?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
11 Replies
5.9k Views
On a view controller shown as part of a UINavigationController's stack, how do I tell if the Back button was pressed? The previously suggested answer from ages ago, to check isBeingDismissed(), seems to always return a false value.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
768 Views
Everything I see from googling says that time travel is gone now on the Apple Watch. However, if I create a brand new watchOS project with complications, there's still a getTimelineEntries(for:after:limit:withHandler) method. So if it exists, how do I use it now, since the setting seems to be gone from the watch app, and if it doesn't, why does the default template still include it?
Posted
by Gargoyle.
Last updated
.