Search results for

column

2,050 results found

Post

Replies

Boosts

Views

Activity

Reply to Loosing precision of a number somewhere
I then use this value and insert it in a Local SQLite DB using the following commandWhat does your database schema look like? Specifically, what is the type of the price column? In general you don’t want to use REAL for currency values because the rules of floating point arithmetic can result in significant rounding errors. In situations like this it is better to store the number of cents in an INTEGER column (that is, fixed point arithmetic). Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Topic: Programming Languages SubTopic: General Tags:
Jun ’16
Reply to Illegal NSTableViewDataSource
I do get the hierarchy you outlined:View ScrollView ClipView TableView Column1 => That's the identifier you use (Where in the code I used this?) TableCellView => That's the identifier you have to use TableViewCell Column2Where did I use the Column identifier? Not sure.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’20
Reply to NSTableView: dynamic columns
I can think of two possible reasons why this might happen:1. You subclass NSTableView to override makeView (withIdentifier:owner:), but you didn't actually cause an instance of the subclass to be created. Can you verify that your custom makeView method is actually executed?Note that the method is makeView, not make, but I assume that's just a typo in your post.2. You create a NSTableCellView, and you add a text field subview, but you have no code to position the text field within the cell, nor any code to set the size of the text view. If its size is zero, or it's positioned outside the parent view, the column will look empty.Your technique for creating these cells is not a good one. Instead, you should do the following:— Create a XIB file that contains a prototype NSTableCellView for the ligne24 column.— For the File's Owner pseudo-object in the XIB, specify the class of your NSTableViewDelegate object (e.g. a view controller class).— Set the cell view's identifier to ligne24.— Add a text v
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’17
Reply to With Swift, can Cocoa Bindings be used to sort by a column in NSTableView?
(It's a while since I had to sort a column, so forgive me if I misremember at any point.)>> I'm using bindings to populate the rows, and I wouldn't expect to set a table view delegate under those circumstancesYou almost always end up wanting a delegate for something or other, so it's usual to have one. But you don't need to do anything with tableView(_:sortDescriptorsDidChange:) in your scenario. The array controller will do the heavy lifting for you.>> do bindings just replace the dataSource … ?Yes, they do. If you use bindings, you don't need a data source (and it can be nil). However, for historical reasons, methods that deal with dragging rows are in the data source protocol, not the delegate protocol. If you need to support dragging, you will need to use a data source after all. In this case, you do not implement the data source methods that the documentation says you must implement. You just implement the ones you need to support dragging.>> I am already using an NSArrayContro
Feb ’18
Reply to This class is not key value coding-compliant error
I changed the code to the following: cellIdentifier = CellIdentifiers.LastUsedCell } if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: nil) as? NSTableCellView { // cell.textField?.stringValue = text cell.textField?.stringValue = Test Field print(cell.textField?.stringValue) return cell With this change it tells me that the issue must be in IB for that column because again the only column that it crashes on is itemUsed. Do you agree? After reading your latest post I changed the code. So, here is how the code looks now with the added print statement along with changing owner to self along with print results from console: } else if currentColumn == fieldIdentifiers.LastUsed { print(LastUsed, CellIdentifiers.LastUsedCell) text = dateFormatter.string(from: currentItem.itemLastused!) cellIdentifier = CellIdentifiers.LastUsedCell } if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier),
Nov ’20
Reply to Importing data via .csv file
Hi @Josedv I'm working on an app with csv read functionality (tapping on a button to open share extension and read a file from Files/...). I managed to find the following in some other thread, which works(ish) for me (I'll explain the ish). I totally agree with @eskimo that you should enforce some sort of formatting rule wherever csv files are generated (this was an ongoing pain at one of my previous jobs), and another pain was to verify the validity of the content, but I guess that's another conversation? It's available from https://github.com/ahltorp/csvparser I used it with Swift 5, and it reads my csv file properly. My csv file was generated using commas as delimiter, nested data as header/detail report style and column order as original. So the ish part, it generates an array of arrays of String ([[String]]), with the first item being the titles for each column (this is particularly useful because this determines the number of columns too, even if one of the rows in that column
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Plist max size
john daniel wrote:I think most people take up more space than that for icons on buttons.Right. But this will be considerably bigger if you put it in an XML plist.@DenisO, For a rectangular array like this I’d probably put the data into a file in binary form and then memory map that. You can then access the values at random and the VM subsystem will take care of the rest.Furthermore, I’d wrap this in a nice, Swift-friendly data structure. Something like this:class DataMap { let rowCount = 16 let columnCount = 16 init?(file: URL) { guard let d = try? NSData(contentsOf: file, options: [.alwaysMapped]) else { return nil } guard d.length == (self.rowCount * self.columnCount * MemoryLayout<Double>.size) else { return nil } self.data = d let base = d.bytes.assumingMemoryBound(to: Double.self) self.buffer = UnsafeBufferPointer(start: base, count: d.length) } private let data: NSData private let buffer: UnsafeBufferPointer<Double> subscript (row: Int, column: Int) -> Double { precondition((0..&
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’17
Reply to SwiftUI TableColumn with Custom Widget not able to Bind
Using a TableColumn requires a Table {// content } rows: { // data source } pattern similar to below. Where in the example rowItems is a collection of Items for the data source. Items struct Item { let from: Date let to: Date let hours: Double } // The table view Table(selection: $selection, sortOrder: $sortOrder) { // Sort column on .from key value path of item TableColumn(From, value:.from) { item in Text(item.from(date: .numeric, time: .omitted)) } // Sort column on .to key value path of item TableColumn(To, value:.to) { item in Text(item.to.formatted(date: .numeric, time: .omitted)) } // Sort column on .hours key value path of item TableColumn(Total, value:.hours) { item in Text(item.hours) } } rows: { // Populate the rows data source with TableRow types containing an item type from the rowItems collection which is passed on each TableColumm. ForEach(rowItems) { item in TableRow(item) } } See Apple example code here: https://developer.apple.com/documentation/swiftui/building_a_g
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22
Reply to NSTextView multiple columns
The general approach is outlined in the Cocoa Text Architecture Guide: Text System Organization – Common Configurations. Look for figure 3-5. You create the components of the text system separately, rather than just creating a text view and having it create the other components for you. You use a single text storage object, a single layout manager, and multiple text containers and text views. Each page-column is associated with a pair of text container and text view. You implement a delegate for the layout manager and implement -layoutManager:didCompleteLayoutForTextContainer:atEnd: to add additional columns and pages, along with their associated text containers and text views, as necessary to accommodate the text.
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’15