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.
Post
Replies
Boosts
Views
Activity
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
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?
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?
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?
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?
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.
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.
I wish to set Calendar.current.date() details to AM or PM
but i do not see any way. or is it possible? how?
there is also a setting called .nanosecond. is this the same as millisecond?
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?
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)
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?
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?
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.
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?