Search results for

column

2,061 results found

Post

Replies

Boosts

Views

Activity

Reply to TabluarData DataFrame removing row results in EXC_BAD_ACCESS
This is most definitely a bug, probably in TabularData itself. I boiled your example down to this: import Foundation import TabularData func test() { let csv = c CCCCCCCCCCCCCCCC var dataFrame = try! DataFrame( csvData: Data(csv.utf8), columns: [c], types: [c: .string] ) dataFrame.removeRow(at: 0) } test() and it crashes in roughly the same way. I’m running this as a command-line tool on macOS 13.4. I tested with both Xcode 14.3 and Xcode 15 beta and it crashes either way. I then put this code into tiny iOS test project and ran it on the iOS 17 beta simulator. It doesn’t crash there, suggesting that the bug has already been fixed. The really interesting thing is that removing a single character from CCCCCCCCCCCCCCCC makes the problem go away. Share and Enjoy Quinn “The Eskimo!” @ DTS @ Apple
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’23
TabluarData DataFrame removing row results in EXC_BAD_ACCESS
I am working with data in Swift using the TabularData framework. I load data from a CSV file into a DataFrame, then copy the data into a second DataFrame, and finally remove a row from the second DataFrame. The problem arises when I try to remove a row from the second DataFrame, at which point I receive an EXC_BAD_ACCESS error. However, if I modify the timings column (the final column) before removing the row (even to an identical value), the code runs without errors. Interestingly, this issue only occurs when a row in the column of the CSV file contains more than 15 characters. This is the code I'm using: func loadCSV() { let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let url = documentsDirectory.appendingPathComponent(example.csv) var dataframe: DataFrame do { dataframe = try .init( contentsOfCSVFile: url, columns: [user, filename, syllable count, timings], types: [user: .string, filename: .string, syllable count: .i
2
0
1.1k
Aug ’23
Reply to iCloud for Mac is stuck on "waiting to upload"
Certainly this iCloud upload being stuck bug is frustrating. My method to resolve it is as follows: Launch Activity Monitor, click on the CPU tab at the top, look for the bird process in the Process Name column, select it, and stop it (kill it) by clicking on the Stop icon on the tool bar (the one with an X inside a circle). You will noticed that the process id number listed in the PID column changes after a couple of seconds, which indicates that the bird process has been restarted by the system (The bird process is responsible of the iCloud background file synchronization). Most of the times this solution will work. If stopping the bird process did not solve the iCloud synching, then perform a full shutdown/restart of your computer. This is the ultimate fix that has always worked for me thus far.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’23
How to get recommendations for new user in MLRecommender model
I have a dataset with 3 columns item_id, user_id, rating. I created a coreML MLRecommender model from this dataset. I want to use this model to get the top 10 predictions for a new user (not in the original dataset) but who has rated a subset of the items in the dataset. I don't see any API in the Apple docs to do this. Both the recommendations APIs only seem to accept an existing user-id and get recommendations for that user. The WWDC tutorial talks about a prediction API to achieve this. But I dont see this in the Apple API documentation and code below from WWDC tutorial cannot be used since it does not give details on how to create the HikingRouteRecommenderInput class it passes into the prediction API. let hikes : [String : Double] = [Granite Peak : 5, Wildflower Meadows : 4] let input = HikingRouteRecommenderInput(items: hikes, k: 5) // Get results as sequence of recommended items let results = try model.prediction(input: input) Any pointers on how to get predictions for new user would be greatl
0
0
523
Jul ’23
How can I create a view with a mixture of Text and TextFields dynamically in SwiftUI
The issue I am encountering is, I need to be able to create a view in SwiftUI that looks like a sentence of text but has blanks where the user can enter their own text. I also need a way to be able to capture the entered text from the binding, but not sure how to do multiple bindings in a loop. Ive tried a few options and the closest I have got is using LazyGrid, but it doesn't look like a normal sentence due to spacing? Any help appreciated. struct MultiText: View { @State var text = There was once a {-} that only had {-} in it. How did they get in? {-} @State var answerText: String = XXXXXXX let rows = [ GridItem(.adaptive(minimum: 80)) ] var body: some View { GeometryReader { geo in HStack { LazyVGrid(columns: rows, alignment: .leading, spacing: 0) { ForEach(text.components(separatedBy: ), id: .self) { component in if component == {-} { TextField(, text: $answerText ) } else { Text(component) } } }.frame(width: geo.size.width * 0.80) Image(systemName: flag).frame(width: 30, height: 30) }.frame(wi
0
0
342
Jul ’23
Reply to SQLite - Testing for existence of a table
It is my understanding that the SELECT statement returns a 0 if the table does not exist and 1 if it does. Actually that statement will return a result row if the table exists, and no result rows if it doesn’t exist. If you really want a result row containing a number every time, then you could use: SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'Contact' But this would require you to fetch the column value to check the number. Your original query actually makes this task easier by letting you simply check if a row was returned or not. the API step statement returns 101 (SQLITE_Done) if the table does not exist. That means sqlite3_step has finished stepping through all the result rows, of which there are none. But if the table does exist it does not return 101. That would be SQLITE_ROW which means it got a result row. If you were to call sqlite3_step once again (or in a loop) you would get SQLITE_DONE the next time.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Help customizing the accessibility of a large UICollectionView
Hello, I am turning to this forum because I suspect I am doing it wrong when it comes to implementing VoiceOver accessibility in my collection view. I suspect this because the system has resisted everything I have tried to do, fought it tooth and nail, and I can't see any way to get this to work. The Collection View I have a collection view that displays a large dataset. It uses a custom collection view layout to create a spreadsheet-like view. It has hundreds of rows, and each row can have hundreds of items. The items in each row do not conform to specific column widths. Their width is defined by the data they display, and for the purposes of this discussion, can be considered to be arbitrary. To the left of the table is a column of sticky headers whose position remains fixed in relation to the content. On top of the table is a row of headers, whose position also remains fixed. The Problem The default accessibility behavior that Apple has baked into UICollectionView is completely impractica
2
0
2.3k
Jul ’23
SwiftUI/Table/Sort: Problem with the sort function on a Table
Hello everyone. I'm having a problem using the table sort function in Swiftui. Here's an example to illustrate (data is provided by an API that returns fake data) : struct CompanyListResponse: Codable { let status: String let code: Int let total: Int let data: [CompanyData] } struct CompanyData: Codable, Identifiable { let id: Int let name: String let email: String } @Observable final class ViewModel { var companies : [CompanyData] = [] func fetch() async { guard let url = URL(string: https://fakerapi.it/api/v1/companies?_quantity=200) else { return } do { let (data, _) = try await URLSession.shared.data(from: url) let decoder = JSONDecoder() let response = try decoder.decode(CompanyListResponse.self, from: data) self.companies = response.data } catch { print(Error fetching data: (error)) } } } struct ContentView: View { @State private var viewModel = ViewModel() @State private var sortOrder : [KeyPathComparator] = [.init(.name, order: SortOrder.forward)] var body: some View { Table(of: CompanyData.self, sort
1
0
941
Jul ’23
Reply to How to capture unknown number of matches using RegexBuilder?
Just want to clarify, suppose I want to parse a table with multiple columns each separated by “|”, I can do one of the followings and use firstMatch(of: regex) or wholeMatch(of: regex), but they assume fixed number of columns in the table. How do I deal with dynamic number of columns? // using multi-line literal let regex = #/ (|) (? (.*?)(?=|)) (|) (? (.*?)(?=|)) (|) (? (.*?)(?=|)) /# // using RegexBuilder let separator = /|/ let regexBuilder = Regex { separator Capture ( OneOrMore(.any, .reluctant) ) separator Capture ( OneOrMore(.any, .reluctant) ) separator Capture ( OneOrMore(.any, .reluctant) ) separator }
Topic: App & System Services SubTopic: General Tags:
Jul ’23
Printing a report of unit tests
Is there a way to print a simple report of the tests? We want a list of tests, with a report of ‘pass’ or ‘fail’ for each one. We need this for the V&V process for our app. We found what we want in the ‘Report Navigator’ (the option on the far right in the left hand column on Xcode) by clicking on ‘Test’. However, this isn’t printable. Below ‘Test’ is ‘Build’, ‘Coverage’, and ‘Log’, which can be exported, but all of them show more information that we wanted. (Photo for reference) Is there a way to print out that page when you click on ‘Test’? What am I missing here?
0
0
561
Jul ’23
UICollectionView minimumLineSpacing bug
I'm creating a horizontal scroll view through the collection view. I used flowlayout for layout, and I set the scroll direction to horizontal. I found a bug in this situation. If the width of the item is different, line spacing is not applied, but item spacing is applied. Since it is a horizontal scroll, line spacing should be applied in the direction of the column, but item spacing is applied. Does anyone know anything about this? // // ViewController.swift // minimumLineSpacingTest // // Created by Hoonki chae on 2023/07/12. // import UIKit class TestCell: UICollectionViewCell { } class ViewController: UIViewController { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = .white self.collectionView.frame = .init(origin: .init(x: 0, y: 100), size: .init(width: self.view.frame.width, height: 50)) self.view.addSubview(self.collectionView) self.collectionView.backgroundColor
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
594
Jul ’23
Reply to Reset Matrix Help
for anyone who might have the same question/problem. here's the sample that works as I wanted. import SwiftUI struct ContentView: View { let numberOfRows = 5 let numberOfColumns = 5 @State var matrix: [[Int]] = Array(repeating: Array(repeating: 0, count: 5), count: 5) @State var selectedRow1 = 0 @State var selectedColumn1 = 0 @State var selectedRow2 = 0 @State var selectedColumn2 = 0 @State var selectedRow3 = 0 var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundColor(.accentColor) Text(Hello, world!) Form { Section(header: Text(Question 1)) { Picker(Select a row:, selection: $selectedRow1) { ForEach(1...numberOfRows, id: .self) { row in Text((row)) } } .pickerStyle(SegmentedPickerStyle()) Picker(Select a column:, selection: $selectedColumn1) { ForEach(1...numberOfColumns, id: .self) { column in Text((column)) } } .pickerStyle(SegmentedPickerStyle()) } Section(header: Text(Question 2)) { Picker(Select a row:, selection: $selectedRow2) { ForEach(1..
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Reset Matrix Help
Hi there! can someone help me with this one: func resetMatrix() { matrix = Array(repeating: Array(repeating: 0, count: numberOfColumns), count: numberOfRows) let coordinates = [ (selectedRow1, selectedColumn1), (selectedRow2, selectedColumn2), (selectedRow3, selectedColumn3) ] for (row, column) in coordinates { matrix[row - 1][column - 1] += 1 } } i can't seem to make it work. i want it to work like this: If the chosen coordinate in Question 1 is (2,2), it will place the value 1 in the matrix coordinate (2,2). If the chosen coordinate in Question 2 is also (2,2), it will increment the value in the matrix coordinate (2,2) by 1, making it 2. Similarly, if the chosen coordinate in Question 3 is (2,2), it will increment the value in the matrix coordinate (2,2) by 1 again, making it 3. Thank you!
1
0
458
Jul ’23
2D-array 5rows X 5 columns matrix HELP
https://drive.google.com/file/d/1GWV9MYs_X4HG0XT4_-wDPPHdWOFwsRJs/view?usp=sharing Hi, everyone! So, I am trying to create an app that is like a survey app. I am new to coding by the way (less than a month) I have this long-ass code that I am trying to work. Well, it is working except for one more part of the code. I've been trying to make it work for days now and I cannot seem to figure it out. I uploaded it in a google drive link above. This is what it is: If you try to run this code in Xcode, you can see a thing like this: The app works like this, users select the pickers beside the Criteria and Relative Risk. The scores will show as: Score: 2,4 (just a sample score) criteria = row relative risk = column what I want to happen is that this score will immediately translate as a coordinate in the risk matrix below. There are 21 sets of pickers for this part of the app. The coordinates can have more than 1 value. so if there are 3 scores that have the same coordinate, such coordinate in the matrix sho
0
0
312
Jul ’23