Post

Replies

Boosts

Views

Activity

Reply to JXA to order Reminders
So no luck with JXA or AppleScript. I've created an app using Swift (at least that should be supported!). Any idea how to modify the manual order of reminders in the Reminders.app using Swift? I have gotten to a point where I can get a reminders list and move them to other lists by changing the .calendar property, however even if I move them in reverse order (move Task 2 and then move Task 1), they appear in the second list in Task 1 then Task 2 order. I suspect there is some property indicating the order or weight. When I used JXA to duplicate an item from the middle of one list to another list (which actually moved instead of duplicating), it appeared in the middle of the destination list and not at the end. As a workaround, I'd be even okay if there was a way to UI script, however, I can't find a way to re-order rows via UI scripting.
Jun ’20
Reply to JXA to order Reminders
Apparently this can't be done at all from EventKit so I'm back to a scripting solution. I have figured out how to do the sort via script, so if I could figure out how to drag a row to reorder, that would work. var app = Application('Reminders'); app.includeStandardAdditions = true; var remindersLists = app.lists; var remindersList = remindersLists.byName('Test'); app.activate(); remindersList.show(); menuItemClick("Reminders", ['View','Sort By','Title']); /* just in case it's already sorted by Priority */ menuItemClick("Reminders", ['View','Sort By','Priority']); At this point, if I could drag a row to another location, that would "lock in" the sort order and be an acceptable (if kludgy) workaround. How can I drag a row to another location within a list using UI scripting? Ideally I could just move a row to another location to lock in the order via scripting instead of UI scripting but I'll take whatever I can get.
Jun ’20
Reply to APNS api address
I got a message about push servers updating. Is this only true/applicable for apps or does this apply to web service code that may use the push notification service (as I'm using)? I too have been using gateway.sandbox.push.apple.com:2195 since 2012 without issue. Will that stop working after the change?
Oct ’20
Reply to App crashes after deleting list item from CoreData - no debug output
I’m having the same problem in Swift Playgrounds for iPad (and I’m not even using CoreData). I’ve put in a bunch of debugging to make sure no indexes are out of bounds, but I’m guessing something is being cached related to the ForEach loop where it’s either referencing the deleted item or using a cached version of the array and not noticing the array has been modified. Note that the debug print statement does not seem to execute before using the index and the list is being edited elsewhere so I think there could be some sort of observer/synchronization issue going on… struct HeartsScoreBox: View {     @ObservedObject var round: HeartsRound     @State var playerIndex: Int     var body: some View {         VStack {             let _ = print("HSB# scores: \(round.playerScores.count), index: \(playerIndex)")             let score = round.playerScores[playerIndex]             Text(String(describing:score))         }     } } And the crash report: Application Specific Information: dyld: dyld4 config: DYLD_INSERT_LIBRARIES=/System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection libswiftCore.dylib: Swift/ContiguousArrayBuffer.swift:575: Fatal error: Index out of range Thread: 0 libswiftCore.dylib closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) 1 libswiftCore.dylib closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) 2 libswiftCore.dylib closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) 3 libswiftCore.dylib closure #1 in _assertionFailure(_:_:file:line:flags:) 4 libswiftCore.dylib _assertionFailure(_:_:file:line:flags:) 5 libswiftCore.dylib _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds(_:wasNativeTypeChecked:) 6 libswiftCore.dylib Array.subscript.getter 7 Previews_HeartsGameView_Thunk_1.dylib closure #1 in HeartsScoreBox.__preview__body.getter /private/var/mobile/Library/Mobile Documents/iCloud~com~apple~Playgrounds/Documents/Score!.swiftpm/Games/Hearts/HeartsGameView.swift:11 8 SwiftUI VStack.init(alignment:spacing:content:) 9 Previews_HeartsGameView_Thunk_1.dylib HeartsScoreBox.__preview__body.getter /private/var/mobile/Library/Mobile Documents/iCloud~com~apple~Playgrounds/Documents/Score!.swiftpm/Games/Hearts/HeartsGameView.swift:9 10 Score! protocol witness for View.body.getter in conformance HeartsScoreBox /<compiler-generated>:0 11 SwiftUI partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:) 12 SwiftUI closure #1 in BodyAccessor.setBody(_:) 13 SwiftUI ViewBodyAccessor.updateBody(of:changed:) 14 SwiftUI DynamicBody.updateValue() 15 SwiftUI partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) 16 AttributeGraph AG::Graph::UpdateStack::update() 17 AttributeGraph AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) 18 AttributeGraph AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, unsigned char&) 19 AttributeGraph AGGraphGetValue 20 SwiftUI GraphHost.updatePreferences() 21 SwiftUI ViewGraph.updateOutputs() 22 SwiftUI closure #1 in ViewRendererHost.render(interval:updateDisplayList:) 23 SwiftUI ViewRendererHost.render(interval:updateDisplayList:) 24 SwiftUI _UIHostingView.layoutSubviews() 25 SwiftUI @objc _UIHostingView.layoutSubviews() 26 UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 27 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) 28 UIKitCore -[UIView(Hierarchy) layoutBelowIfNeeded] 29 SwiftUI closure #3 in performUpdates #1 <A, B>() in UITableViewListCoordinator.updateUITableView(_:to:transaction:) 30 SwiftUI thunk for @callee_guaranteed () -> () 31 SwiftUI thunk for @escaping @callee_guaranteed () -> () 32 UIKitCore +[UIView(Animation) performWithoutAnimation:] 33 SwiftUI performUpdates #1 <A, B>() in UITableViewListCoordinator.updateUITableView(_:to:transaction:) 34 SwiftUI thunk for @callee_guaranteed () -> () 35 SwiftUI thunk for @escaping @callee_guaranteed () -> () 36 UIKitCore +[UIView(Animation) performWithoutAnimation:] 37 SwiftUI closure #2 in UITableViewListCoordinator.updateUITableView(_:to:transaction:) 38 SwiftUI thunk for @escaping @callee_guaranteed () -> () 39 SwiftUI static Update.end() 40 SwiftUI static NSRunLoop.flushObservers() 41 SwiftUI closure #1 in closure #1 in static NSRunLoop.addObserver(_:) 42 SwiftUI specialized thunk for @callee_guaranteed () -> (@error @owned Error) 43 libswiftObjectiveC.dylib autoreleasepool<A>(invoking:) 44 SwiftUI closure #1 in static NSRunLoop.addObserver(_:) 45 SwiftUI @objc closure #1 in static NSRunLoop.addObserver(_:) 46 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ …
Sep ’22
Reply to App crashes after deleting list item from CoreData - no debug output
Found a fix! (Credit: https://blog.apptekstudios.com/2020/05/quick-tip-avoid-crash-when-using-foreach-bindings-in-swiftui/) Add this extension and then when referencing the index, use [safe:index] and everything works as expected! // Fix for race condition issue extension Binding where Value: MutableCollection {     subscript(safe index: Value.Index) -> Binding<Value.Element> {         // Get the value of the element when we first create the binding         // Thus we have a 'placeholder-value' if `get` is called when the index no longer exists         let safety = wrappedValue[index]         return Binding<Value.Element>(             get: {                 guard self.wrappedValue.indices.contains(index)                 else { return safety } //If this index no longer exists, return a dummy value                 return self.wrappedValue[index]             },             set: { newValue in                 guard self.wrappedValue.indices.contains(index)                 else { return } //If this index no longer exists, do nothing                 self.wrappedValue[index] = newValue             })     } }
Sep ’22