Post

Replies

Boosts

Views

Activity

Does it possible to release another online version of exist app
I have deleoped a tool app for record things and schedule time , and fully offline, so it's easy to use and dont need to worry about data leak. But AI move so fast, i want to integrate into this app, help user get more insight from recorded things or better plan. Also simplify cross-device data sync (now user need import/export for backup or sync); So there're two options for me: Integrate AI directly into current apps , online features (AI/Account) as additional services . But this might break user experience, or uninstall app afraid of privacy leak. Create new version from current code base, and release as new app with online features. Old version keep update focus on offline experience. The second option balanced user experience and most acceptable, but I dont know Apple will reject my second one or not? (because there're many same functions),
2
0
356
Feb ’24
NotificationCenter.default not trigger UserDefaults.didChangeNotification at extension widget?
expect: app update UserDefaults use group value. widget use NotificationCenter.default observe same group UserDefaults, then reloadTimeline actual: successfully set no reload happen, and I try set same key to another value inside the selector function to test whether it's been called. provided the selector not work. steps: click a app button to set a key of UserDefaults back home , widget no change - expect it update view based one new value rebuild widget , can see the ui use new value - prove set call successfully but notification of UserDefaults.didChangeNotification not send host app : UserDefaults(suiteName: "group.a") store?.setValue("a", forKey: "target") widget: class NotiWatch {    init(){         NotificationCenter.default.addObserver(self, selector: #selector(onchange), name: UserDefaults.didChangeNotification, object: nil)     }     @objc func onchange(notification: NSNotification) {         UserDefaults(suiteName: "group.a")?.set("cccc", forKey: "target") WidgetCenter.shared.reloadAllTimelines()     }     deinit{         NotificationCenter.default.removeObserver(self, name: UserDefaults.didChangeNotification, object: nil)     } } struct Provider: TimelineProvider {     let def:UserDefaults? ;     let watcher = NotiWatch()     init(){         let fmt = DateFormatter()         fmt.dateFormat = "yyyy-MM-dd HH:mm"         dd = fmt.date(from: "2070-12-20 23:59")!         def = UserDefaults(suiteName: "group.a") ;     }     var dd =  Date()     func placeholder(in context: Context) -> SimpleEntry {         SimpleEntry(date: Date(), unit: "Y",left: 0,tar: "")     }     func getSnapshot(  in context: Context, completion: @escaping (SimpleEntry) -> ()) {         let date = Date()         let left = dd.timeIntervalSince(date).minutes         let entry = SimpleEntry(date: date, unit: "M",left: left,tar: "")                   completion(entry)     }     func getTimeline( in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         var entries: [SimpleEntry] = []         // Generate a timeline consisting of five entries an hour apart, starting from the current date.         let tar = def?.string(forKey: "target") ?? ""         let currentDate = Date()         for offset in 0 ..< 60 {             let entryDate = Calendar.current.date(byAdding: .minute, value: offset, to: currentDate)!                          let left = dd.timeIntervalSince(entryDate).minutes             let entry = SimpleEntry(date: currentDate, unit: "minutes",left:left,tar: tar)             entries.append(entry)         }         let timeline = Timeline(entries: entries, policy: .atEnd)         completion(timeline)     } }
2
0
973
Dec ’22
Timer not running at some class
I have a simple class to interval run some code when call it start ; // Test.swift public class Test { var timer Timer? public func start(){ // print("2“) // print timer = Timer.scheduledTimer(5,true,{ // code here print("3") // not print } // RunLoop.current.add(timer,forMode:.commonMode) // uncomment this line also not work } } // Class2.swift class Class2: ParentClass{ private let test = Test() @objc public func check(flag:String){ if flag == "Y" { print("1") test.start() } } } But the timer seems not work --- not print "3" But I try to create a timer at some other class, it work, just at Test class not run .... Anyone know why ?
0
0
519
Jun ’22