Post

Replies

Boosts

Views

Activity

touch events do not work in ipad air and pro
what happened? i never noticed it until i decided to use ipad air and pro as option in chrome dev console mobile view as well as ios simulator. it works ok in the ipad mini. touch events do not get triggered. instead, the scroll seems to overlap these. EDIT: Solved. please see comment below. While it works ok in ipad pro devices now, I still wish this could work out in chrome's dev console ipad pro view. the behavior is different with click events. instead of mouse down, it starts with mouse move. what gives? this only happens in ipad air and pro view in the device toolbar in dev console.
1
0
732
Jan ’24
Incorrect rounding off result
Hi, what do you think is wrong with the fucntion. This is what I have. Could it be because of the roundmode type used? static func roundOff(_ val: String, _ decimalPlace: Int) -> String {     let decimalFormatter = createDecimalFormatter()     decimalFormatter.minimumFractionDigits = decimalPlace     decimalFormatter.maximumFractionDigits = decimalPlace     let bigDecimal = NSDecimalNumber(string: val)     return decimalFormatter.string(from: bigDecimal.rounding(accordingToBehavior: NSDecimalNumberHandler(roundingMode: .up, scale: Int16(decimalPlace), raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)))!   }   static func roundOff(_ value: Double, _ decimalPlace: Int) -> String {     return roundOff(String(value), decimalPlace)   } roundOf("75.2", 0) returns 76 instead of 75
2
1
472
Mar ’23
Replace substring using regex in a string
Hi all. I am not sure what is wrong with my current code. What I am looking to do is change all values of a string with a substring of "around #C" where # is the temperature. I am converting between farenheit and celsius and i wish to get all substrings then change the correct value depending on the current setting. So if i have a string where "This is today. The temperature is around 14C. Tomorrow the temperature will be around 18C" So the regex would get "around 14C" and "around 18C" and change the values to farenheit. Result would be something like "This is today. The temperature is around -1F. Tomorrow the temperature will be around -4F" This is my function. func formatCorrectDetail(_ detail: String, _ isCelsius: Bool) -> String {     let regex = try! NSRegularExpression(pattern: "around ((\\d+)" + (isCelsius ? "F" : "C") + ")", options: [])     let matches = regex.matches(in: detail, options: [], range: NSRange(location: 0, length: detail.utf16.count))     let formattedString = NSMutableString(string: detail)     for match in matches {       let range = match.range(at: 2)       if let rangeSubstring = Range(range, in: detail),         let temperature = Double(String(detail[rangeSubstring])) {         let val = isCelsius ? NumberTool.far2cel(temperature) : NumberTool.cel2far(temperature)         formattedString.replaceCharacters(in: range, with: val)       }     }     if formattedString.length > 0 {       return String(formattedString)     }     else {       return detail     }   } The NumberTool.far2cel() and NumberTool.cel2far() are my custom functions to convert between celsius and farehnheit. Thoughts?
3
1
620
Mar ’23
Build Input File Cannot Be Found .app
This one is about the .app not found. I am not sure why. And i have not seen a post about a .app not being found. Build input file cannot be found: '.../DerivedData/...../Build/Products/Debug-iphonesimulator/......app/.....'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? Thoughts what could be wrong?
1
0
764
Mar ’23
BGTaskScheduler.shared.register() does not get called
Hi all. Any clue why BGTaskScheduler.shared.register() does not get called? The print does not show anything to console. I already registered them in Permitted Background task scheduler identifiers and added 2 items for package.Task.updateAppRefresh package.Task.updateAppProcessing I re-read the tutorial and I cannot figure out what else i am lacking? Thoughts?
2
0
1.1k
Mar ’23
Why does date only object always has 16:00:00 time? instead of 00:00:00
So ive read there is no feature in the Foundation package that outputs a date only object. Ive tried variations seen in forum posts. One of them is like this. But i am confused why the output is always 16:00:00 +0000 for the time instead of 00:00:00 +0000? This is the code Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())! 16:00:00 is 4PM. Instead of 12:00AM When I run it in this site online swift playground https://online.swiftplayground.run/ i get this output 2023-02-26 23:00:00 +0000 I figure this could be because of timezone. But is there a way to get a date object where the value of time is midnight? 00:00:00? Thoughts?
1
0
540
Feb ’23
Callback Function As Parameter
My sample function is this func temp(type: String, callback: (() -> Void)? = nil) { callback?() } But why can't I do this? temp(type: "Here", () -> { print("hey") }) It says, Expected type after '->' While this does work temp(type: "Here", { () -> Void in print("hey") }) I find it weird why the () -> Void has to be inside the closure.
3
0
2.2k
Feb ’23
Background Service To Fetch Data
Hi all. This is more of a discussion thread than a question about getting some code answers. I am reading about background tasks and the Apple documentation example is not even complete and unusable. Just bits and pieces of code so a newbie like me doesnt find it helpful. What I am trying to do is run a background task even when the app is closed at 3 hour intervals. I have not seen any solution to this. is this possible? I figured trying to also look if it is possible to listen to when the user's internet connection is on or off because once it will be one, the service will run. if the internet is turned off, it disables the service (is this possible?) I used this url as guide https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app#3193599 Note: I dont even know what RefreshAppContentsOperation is. At least they should have included the source for this. Or even if it's part of the sdk, at least include the import for this.
0
0
545
Feb ’23
How to set instance of a property of the same class type
See sample class class A { var proxy: A init () { proxy = self } } In Java, i could do something like this class A { A proxy; A () { proxy = this } } so when i instantiate A sample = new A(); the proxy variable will be set to the "this" keyword. But in Swift, the only related keyword to it is self but it does not behave the same way. It merely serves somewhat of a pointer to properties and methods that it belongs to it. Is this possible in Swift? if yes, how to go about this? I could not find any solution (perhaps because there is a term for that style? which I have no clue about) thoughts?
1
0
502
Feb ’23
For Loop Conversion in Swift
Hi, i have only seen for loop samples that involve indexes or using for item in items. I come from a java background and i cannot seem to confirm if this can actually be converted to a swift for loop. thoughts? for (EdgeNode edge = aet.topNode ; (edge != null); edge = edge.next)
1
0
480
Feb ’23
Deploy Release App To Device
I have a question regarding releasing an app to a device. I tried to release a debug app but I noticed that when i disconnect the cable from the device, the app cannot be run anymore. So instead, I have to transfer a release app to the device. However, there are some things I do not understand with regards to profiles. Do i have to create a provisioning profile just to be able to have my release built app installed in my iPhone? Or is there another way. Because while looking into this, I came to a conclusion that I have to have a developer account (which forces me to pay 100usd per year). And i have no plans to publish any app until I manage to finish 3 of them. I only plan to get a developer account once. all 3 are tried and tested in a real device. Thoughts?
0
0
389
Feb ’23
Possible to set body view's background to transparent?
Please see screenshot. Currently the one in white has an animation in the middle. i wish to set the background of the body's view to transparent so that only the animation from my app is visible (it's like the home screen but only my animation is shown when the app is run. Is that possible? I tried to set VStack's background color opacity to 0 but nothing happpens. Or is it something else that needs to be modified? Thoughts?
1
0
480
Jan ’23
Why Does Image Overlap In GridRow?
struct TweetFeedSelectionGridView: View {   private let ICON_SIZE: CGFloat = 40   private let ROW_BOTTOM_PADDING: CGFloat = 40       var body: some View {     Grid(alignment: .top, verticalSpacing: ROW_BOTTOM_PADDING) {       createTwitterFeedRow(["TwitterDilg", "TwitterDoh", "TwitterDole"])       createTwitterFeedRow(["TwitterDswd", "TwitterDepEd", "TwitterMmda"])       createTwitterFeedRow(["TwitterNdrmmc", "TwitterPagasa", "TwitterPcoo"])       createTwitterFeedRow(["TwitterPhivolcs", "TwitterPia", "TwitterPna"])       createTwitterFeedRow(["TwitterPnp", "TwitterRedCross", "TwitterTxtFire"])     }     .frame(maxWidth: .infinity)     .background(.red)   }       @ViewBuilder   func createTwitterFeedRow(_ feeds: [String]) -> some View {     GridRow {       createTwittedFeedCell(feeds[0])       createTwittedFeedCell(feeds[1])       createTwittedFeedCell(feeds[2])     }     .frame(maxWidth: .infinity)   }       @ViewBuilder   func createTwittedFeedCell(_ iconLabel: String) -> some View {     VStack {       Image(uiImage: UIImage(named: iconLabel)!)         .frame(width: ICON_SIZE, height: ICON_SIZE)       Text(iconLabel.replacingOccurrences(of: "Twitter", with: ""))         .padding(.top, 10)     }   } } struct TwitterFeedSelectionGridView_Previews: PreviewProvider {   static var previews: some View {     TweetFeedSelectionGridView()   } } Why does the image in the first row overlap? I have no clue why. The image is an ImageSet of 80, 160 and 240x240 images.
2
0
569
Jan ’23
How To Create Data Json Object from Empty String
This is what I tried to do. I am not sure what is wrong. anyone got ideas? let data: Data? = try? JSONSerialization.data(withJSONObject: "") and it says reason: '*** +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write' even if i put in "{}" error is the same. thoughts? Purpose for this is i want set this to a URLRequest.httpBody Thoughts?
1
0
934
Jan ’23