Post

Replies

Boosts

Views

Activity

Reply to Problems Updating a View
That (kinda) Worked! I think it did work, but you now move on to different questions! Also, why can't I just put objectWillChange.send() in the Data class? That will send objectWillChange for the data object, not for the NFCReader object (which is what ContentView is observing).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to MPSMatrixDescriptor warning
The convenience initializer: init(dimensions rows: Int, columns: Int, rowBytes: Int, dataType: MPSDataType) ...has been deprecated. It looks like you should instead use: init(rows: Int, columns: Int, rowBytes: Int, dataType: MPSDataType) This seems to be the same, since the deprecated initializer replaces "dimensions" with "rows" anyway.
Topic: Graphics & Games SubTopic: Metal Tags:
Feb ’22
Reply to How to convert Data into struct in Swift
You can better show your target struct in a code block, like this; struct ins_gyro_info { int64_t timestamp; //millisecond double gravity_x; double gravity_y; double gravity_z; double rotation_x; double rotation_y; double rotation_z; }; Then the question is, what is the format of your Data? What method is returning it, and how is it structured? Then we can convert from your Data to your struct.
Topic: App & System Services SubTopic: General Tags:
Feb ’22
Reply to How to increase or decrease the probability of an item being picked from an array?
Chance of 1 being picked at 10% Chance of 2 being picked at 20% Chance of 3 being picked at 30% Chance of 4 being picked at 35% Chance of 5 being picked at 5% I would try something like this: Get a random number between 1 and 100 (since you are using percentages, that makes it easy) Allocate ranges between 1 and 100, depending on your probabilities... func randomIndex() -> Int { switch Int.random(in: 1...100) { case 1...10: return 0 case 11...30: return 1 case 31...60: return 2 case 61...95: return 3 default: return 4 } } This returns a random index to your array, based on the probabilities you have given. It hard-codes the 5 values and probabilities, but you could write a more advanced/flexible version, if that would suit your use-case better. Rather than returning an index, you could do the look-up in the function, like this: func chooseFromArray() -> String { switch Int.random(in: 1...100) { case 1...10: return numbers[0] case 11...30: return numbers[1] case 31...60: return numbers[2] case 61...95: return numbers[3] default: return numbers[4] } } Note that your array contains "Strings", not "Numbers"!
Feb ’22
Reply to How to move objects to the right side?
Set frame and alignment: .frame(maxWidth: .infinity, alignment: .trailing) Within the List, "Group" your items, so that frame and alignment apply to them all: NavigationView { VStack { List { Group { Label(title: { Text("tv") }, icon: { Image(systemName: "tv")}) Label(title: { Text("another tv") }, icon: { Image(systemName: "tv")}) } .frame(maxWidth: .infinity, alignment: .trailing) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’22
Reply to CoreLocation data across multiple apps
significant location changes When iOS detects that a significant location change has occurred, it passes that information on to all apps which have registered to use the "Significant-Change Location Service". The location change is not "triggered" by any app. It is detected by iOS, and passed on to the app(s), which can then "trigger" an action in the app(s). See https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant-change_location_service
Feb ’22
Reply to WYSWYG HTML rendering of iOS/Android devices displayed on Mac OSX application or iOS app (scaled)
WKWebView is not reliable as it comes to these features, and it is a development tool Where are you getting this information from? WKWebView is the standard way of displaying HTML content in an iOS or macOS app. "A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app’s UI." See https://developer.apple.com/documentation/webkit/wkwebview
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to WYSWYG HTML rendering of iOS/Android devices displayed on Mac OSX application or iOS app (scaled)
Okay... I'm not sure what you are asking now. An iOS or macOS ("OSX" is long gone) can use a WKWebView to display web content. This will work on a Simulator, or a real device. The WKWebView can be adjusted, using it's contentMode property (e.g. "scaleToFill")... ...or you can inject some javascript, to customise the HTML content in other ways (I don't do this, but a quick Internet search will return various code snippets). Have you tried this? If no, that would be your first step. If yes, what don't you like about it, and what do you want to do differently?
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to Problems Updating a View
As a test, in NFCReader, after addItem(), try forcing the update by adding: objectWillChange.send()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Problems Updating a View
That (kinda) Worked! I think it did work, but you now move on to different questions! Also, why can't I just put objectWillChange.send() in the Data class? That will send objectWillChange for the data object, not for the NFCReader object (which is what ContentView is observing).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to I want to limit the list of compatible devices for my ios app.
Interesting that you say it is possible to restrict an Android app to iPad-only! To achieve this in Xcode, go to Target > Deployment Info check "iPad" uncheck "iPhone
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to New OLM to PST Converter Free Software download
Reported as spam.
Replies
Boosts
Views
Activity
Feb ’22
Reply to MPSMatrixDescriptor warning
The convenience initializer: init(dimensions rows: Int, columns: Int, rowBytes: Int, dataType: MPSDataType) ...has been deprecated. It looks like you should instead use: init(rows: Int, columns: Int, rowBytes: Int, dataType: MPSDataType) This seems to be the same, since the deprecated initializer replaces "dimensions" with "rows" anyway.
Topic: Graphics & Games SubTopic: Metal Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to How to convert Data into struct in Swift
You can better show your target struct in a code block, like this; struct ins_gyro_info { int64_t timestamp; //millisecond double gravity_x; double gravity_y; double gravity_z; double rotation_x; double rotation_y; double rotation_z; }; Then the question is, what is the format of your Data? What method is returning it, and how is it structured? Then we can convert from your Data to your struct.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to How to increase or decrease the probability of an item being picked from an array?
Chance of 1 being picked at 10% Chance of 2 being picked at 20% Chance of 3 being picked at 30% Chance of 4 being picked at 35% Chance of 5 being picked at 5% I would try something like this: Get a random number between 1 and 100 (since you are using percentages, that makes it easy) Allocate ranges between 1 and 100, depending on your probabilities... func randomIndex() -> Int { switch Int.random(in: 1...100) { case 1...10: return 0 case 11...30: return 1 case 31...60: return 2 case 61...95: return 3 default: return 4 } } This returns a random index to your array, based on the probabilities you have given. It hard-codes the 5 values and probabilities, but you could write a more advanced/flexible version, if that would suit your use-case better. Rather than returning an index, you could do the look-up in the function, like this: func chooseFromArray() -> String { switch Int.random(in: 1...100) { case 1...10: return numbers[0] case 11...30: return numbers[1] case 31...60: return numbers[2] case 61...95: return numbers[3] default: return numbers[4] } } Note that your array contains "Strings", not "Numbers"!
Replies
Boosts
Views
Activity
Feb ’22
Reply to How to move objects to the right side?
Set frame and alignment: .frame(maxWidth: .infinity, alignment: .trailing) Within the List, "Group" your items, so that frame and alignment apply to them all: NavigationView { VStack { List { Group { Label(title: { Text("tv") }, icon: { Image(systemName: "tv")}) Label(title: { Text("another tv") }, icon: { Image(systemName: "tv")}) } .frame(maxWidth: .infinity, alignment: .trailing) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to CoreLocation data across multiple apps
significant location changes When iOS detects that a significant location change has occurred, it passes that information on to all apps which have registered to use the "Significant-Change Location Service". The location change is not "triggered" by any app. It is detected by iOS, and passed on to the app(s), which can then "trigger" an action in the app(s). See https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant-change_location_service
Replies
Boosts
Views
Activity
Feb ’22
Reply to Language translator offline
What platform... macOS? tvOS? iPadOS? What languages?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to Language translator offline
Friendly tip: when people answer your questions, always answer them, don't just ignore them.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to WYSWYG HTML rendering of iOS/Android devices displayed on Mac OSX application or iOS app (scaled)
WKWebView is not reliable as it comes to these features, and it is a development tool Where are you getting this information from? WKWebView is the standard way of displaying HTML content in an iOS or macOS app. "A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app’s UI." See https://developer.apple.com/documentation/webkit/wkwebview
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to WYSWYG HTML rendering of iOS/Android devices displayed on Mac OSX application or iOS app (scaled)
Okay... I'm not sure what you are asking now. An iOS or macOS ("OSX" is long gone) can use a WKWebView to display web content. This will work on a Simulator, or a real device. The WKWebView can be adjusted, using it's contentMode property (e.g. "scaleToFill")... ...or you can inject some javascript, to customise the HTML content in other ways (I don't do this, but a quick Internet search will return various code snippets). Have you tried this? If no, that would be your first step. If yes, what don't you like about it, and what do you want to do differently?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to add json file unhandled err
Do you have a question?
Replies
Boosts
Views
Activity
Feb ’22