I used to be able to click on "Search Documentation" on the quick help popup, but the option isn't available anymore.
I'm using Xcode 11.6 Was it removed?
Post
Replies
Boosts
Views
Activity
I have a NSTableView under a NSViewRepresentable and I'm trying to add a new row when the + button is clicked.
With the code below, the ForEach statement is updated when the data is added to the state variable, but the table view doesn't show the new element.
Why is that?
import PlaygroundSupport
import SwiftUI
struct TV: NSViewRepresentable {
@Binding var students: Array<String>
func makeNSView(context: Context) -> NSScrollView {
let sv = NSScrollView()
let tv = NSTableView()
sv.documentView = tv
tv.gridStyleMask = .solidHorizontalGridLineMask
tv.usesAlternatingRowBackgroundColors = true//
tv.allowsMultipleSelection = true
let col = NSTableColumn(identifier: NSUserInterfaceItemIdentifier(rawValue: "Name"))
col.title = "Name"
_ = tv.addTableColumn(col)
_ = tv.delegate = context.coordinator
tv.dataSource = context.coordinator
return sv
}
func updateNSView(_ nsView: NSScrollView, context: Context) {
(nsView.documentView as! NSTableView).reloadData()
}
func makeCoordinator() -> Coordinator {
Coordinator(self, students: self._students)
}
class Coordinator: NSObject, NSTableViewDelegate, NSTableViewDataSource {
var parent: TV
@Binding var students: Array<String>
init(_ parent: TV, students: Binding<Array<String>>) {
self.parent = parent
self._students = students
}
func numberOfRows(in tableView: NSTableView) -> Int {
return students.count
}
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
print(students[row])
return students[row]
}
func tableView(_ tableView: NSTableView, shouldEdit tableColumn: NSTableColumn?, row: Int) -> Bool {
return true
}
func tableView(_ tableView: NSTableView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, row: Int) {
self.students[row] = object as! String
}
}
}
struct view: View {
@State var students = ["John", "Mary", "Bob"]
@State var minusDisabled: Bool = true
var body: some View {
Group {
VStack(alignment: .leading) {
Text("Test")
TV(students: self.$students).frame(width: 400, height: 300)
HStack {
Button(action: {
self.students.append("New Row")
}) {
Text("+")
}.buttonStyle(BorderedButtonStyle())
Button(action: {
}) {
Text("-")
}.buttonStyle(BorderedButtonStyle())
.disabled(self.minusDisabled)
}
}.fixedSize()
ForEach(self.students, id: \.self) { student in
Text(student)
}
}
}
}
PlaygroundPage.current.setLiveView(view().frame(width: 500, height: 800))
When I try the code below on Playground, res is always nil. I tried different Javascript commands. Any ideas why?
import Cocoa
import WebKit
let url = URL(string: "SOMEURL")!
let config = WKWebViewConfiguration()
let prefs = WKPreferences()
prefs.javaScriptEnabled = true
config.preferences = prefs
let webView = WKWebView(frame: .zero, configuration: config)
let navDel = NavDel()
webView.navigationDelegate = navDel
webView.load(URLRequest(url: url))
class NavDel: NSObject, WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
DispatchQueue.main.async {
let js = "document.documentElement.textContent"
webView.evaluateJavaScript(js) { (res, error) in
guard error != nil else {
print(error?.localizedDescription)
return
}
print(res) // returns nil
}
}
}
}
`
When I add a TextField inside a List, the TextField is grayed out and the user cannot change its value.
If I place the same TextField outside a List, it works fine.
Any ideas on how to make the TextField editable?
I'm trying to add help files to my Mac OS application. I've been reading the documentation below, but I'm not sure how to apply to my project as there isn't any Resources folder:
https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/ProvidingUserAssitAppleHelp/authoring_help/authoring_help_book.html#//apple_ref/doc/uid/TP30000903-CH206-CIHEHEAC
Is there an updated version of Apple Documentation on how to create help files?
I need to build something similar to the image grid view being used in the SF Symbols application, but I'm not sure how to implement such a grid view without using the beta grid views announced recently.
The grid view needs to auto resize like how it's doing in the SF Symbols application.
Is it possible to use standard SwiftUI views to build something like it?
Screenshot for the SF Symbols view referred here - https://www.icloud.com/iclouddrive/0Pz5ojQxoQeB9zsKOG1oczO0Q#Screen_Shot_2020-06-23_at_11.03.45_PM