NSTableView cuts off content - swift

I'm building in content inside of a NSTableView, but when I compile and run, it cuts off the top half of all the content within the NSTableView. I'm brand new to the Swift language so I am quite lost here. I can provide further examples as necessary. Is there something simple I am missing first or is this more specific to my use case?

I can quickly give you a few directions to go looking for help.
Firstly the Apple Documentation for it. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/PopulatingView-TablesProgrammatically/PopulatingView-TablesProgrammatically.html
You may note that there are essentially two ways of populating the table view, programmatically by implementing the methods of NSTableViewDataSource and NSTableViewDelegate protocols. And by using Cocoa Bindings. I recommend, as a beginner, to use the first option and look at either example code or videos that use these protocols.
Secondly, this may be just a UI issue in your storyboard, make sure your constraints are set properly. You may just have some weird behavior going on here with other views.
Unfortunately, I cannot give you more help without code snippets or more information

Related

How to *include* a model in multiple views / structs in SwiftUI xcode

This is a very noob question. I'm proficient in css, but swift is new to me and so I am trying to think object based, but it's not natural yet. I have tried to understand MVVM which I think is core to the problem but I'm not sure so asking for help.
I want to create an app which has an 'index' central nav type view which I have put in contentview. Depending on what button is pressed I want it to invoke series of functionality but there are up to 9 different types of function that are entirely independent of each other. In html / css, I'd have a central nav index and 'link' to other function specific capabilities.
I don't want to repeat code, so I am trying to work out how to create an architecture that supports it. Where I am getting stuck is in the scoping of it as it is telling me 'this variable isn't in scope'. Fine. I understand the concept but not how to do it right. And I've watched hundreds of hours of video and still not found anything. As an illustration, say the contentview was main actor, and it was a navigator for topics on cats, dogs, lizards, snakes, horses, and pigs.
My thinking is that I'd keep contentview as the nav, and have separate swift files cat.swift, dogs.swift, lizards.swift etc and include them into contentview so their content was globally available. In each of those files I'd have the let catName = etc and much more content specific to that function area. But then from within cat.swift I'd also want to include dog.swift, horse.swift etc as well so the user can navigate those too. In css I'd do this via links - which is probably utter idiocy in swift.
So how do I do this in swiftUI? I don't in detail know the detailed differences between #stateObject, and #state and private var versus var etc and have tried to find a guide that says 'if you want 'catModel' to be available throughout the app define it anywhere with #makeitavailableeverywhere catModel and just trigger it into the view you want by '#include catModel'.
Not sure if this makes sense, but if someone can point me to where I can get accessible, translation into how to do this I'd be so grateful. The app is nearly complete - and I'm pleased, I just can't get the different .swifts to be in scope to each other.
Thank you!

Creating a List of Custom Views in Xcode

I'm currently working on developing a desktop application for MacOS for downloading batches of audio files from URLs at one time I've run into a question about UI design that I can't figure out.
I have a class called SongEntry.swift that holds information regarding the URL that was entered (e.g. url, title, length, author, etc.) and I want to create a vertically growing list of custom views that updates when a new one is added.
Where is what the base view looks like:
Inside of the big white area is where I want the list to be held.
I've tried to create a separate view controller that handles each entry but that didn't work. I know UI design for MacOS is much different from iOS, however I think what I'm looking for is a way to simulate the table views and cell prototypes from iOS but can't find a suitable option.
If anyone knows of a possible solution or can point me in the right direction, I'd greatly appreciate it!
What you want is one of the collection views. For vertical list, you'll probably use NSTableView with only one column and hide everything else like headers.
Here are roughly the steps you need:
You can use your existing view controller or create a dedicate view controller for just the table (and use the 'embed' option in Interface Builder)
This view controller will adopt the NSTableViewDataSource and NSTableViewDelegate protocols to provide the data (your SongEntry objects) and the view for each row.
You set your NSTableView's source and delegate to your view controller.
You create a view which will serve as your "cell", it will be used by each row to display the data. You can design it either in IB or in code.
The entire process is described in detail in the Table View Programming Guide for Mac.
This topic can be a bit confusing. Note that there are two main approaches: the view-based and NSCell-based tables. Don't bother with the NSCell way, it's more of a legacy leftovers.
Also note that there are some overlap of methods in both NSTableViewDataSource and NSTableViewDelegate to provide data and views that can be a bit confusing at first. Just play around with the code and samples and it will be clearer which delegate method to use when.
There are many examples both on Apple's developer site and github. Also a good tutorial on raywenderlich.com.

Is it possible to configure a NSTableView to have Sections?

I would like to create a Table View to display a list of items that users can click to start actions and would like to visually group them in categories.
In iOS is relatively easy have sections in a Table View but in macOS I haven't find documentation about this.
I found this article by Marcin Krzyżanowski of May 2015 http://blog.krzyzanowskim.com/2015/05/29/lets-talk-about-sections-for-nstableview/, it's excellent but I would like to implement a simpler solution to avoid problems when maintaining code I don't understand well.
I haven't managed to find a way to use sections in NSTableView either, and I like your approach...don't just copy and paste code you don't understand :)
What I have done when I needed sections in a macOS app was to use the "new" NSCollectionView (https://developer.apple.com/reference/appkit/nscollectionview) (it has been around since 10.5 but got a major overhaul in 10.11). It is somewhat similar to UICollectionView and gives you the ability to use sections.
So...
Instead of UICollectionViewDataSource you have NSCollectionViewDataSource (https://developer.apple.com/reference/appkit/nscollectionviewdatasource)
where you can use numberOfSections(in:) and collectionView(_:numberOfItemsInSection:) for instance. Furthermore you have makeSupplementaryView(ofKind:withIdentifier:for:) which can be used to create your section header views.
This tutorial from Ray Wenderlich is worth having a look at.
I know it is not exactly what you were looking for but maybe you can use it. Good luck :)

Swift and Parse - PFQueryTableViewController loadingViewEnabled

Good day! I'm using Parse for my swift project, Specifically the PFQueryTableViewController but i want to change the loading view when i open the app. It doesn't look good in my background so i want to change its color and shadow. Also its UIActivityIndicatorView. Is it possible to change this things? Here is the Screenshot for it.
I tried searching for that method in ParseUI framework but i can't find it. I hope you can help me, Thanks!
Only the table controller is unique to Parse. The spinner is just a regular UI element. Thus, the iOS developer references are good places to look for this.
Try this link for the activity spinner:
This link shows information about the controller, which shows that it simply inherits from UITableViewController, and the cells/background can be styled accordingly.
In general, Parse tries to prefix its objects with PF.

Any code examples for using a UITableView to implement in-app settings?

Any code examples for using a UITableView to implement in-app settings?
That is where to get the iPhone settings app look and feel one custom builds the settings into a UITableView. So you you would custom set the sections and cells that get returned with switch type statements.
In particular interested in reviewing the coding approach for how to:
best configure the cellForRowAtIndexPath and didSelectRowAtIndexPath
how to handle those cells for which you want in cell editing (e.g. text)
those cells where you need to launch off into another screen to set a date/time for example
how to collect up parameters and pass back to calling rootViewController (in my case need to persist data out to Core Data persistence)
Note: using Core Data so not interested in using libraries such as InAppSettings [any feedback re whether such libraries might be ok appreciated at this SO question I created].
thanks
I am not sure if you can use the inappsettingskit for your needs. It is open source so you are free to modify the code as you wish, but it doesn't look as an out of the box solution.
If you want to make these settings available in the settings app you will have to live with some workarounds for example saving NSDate AND getting a nice UI control to modify it: Use a textfield, there is no control specified which let's you pick a date. Have a look at Apple's documentation.
So the last option will be coding. First of all, determine what kind of types you want to support. Then create custom TableViewCells which reflect those kinds. If some kinds do need some special way of editing, for example a color picker, you'll have to write those controllers as well. You set a cell into editing mode with the delegate method tableView:didSelectRowAtIndexPath and present the custom controller or get into editing directly for example a UITextField. A Slider is handled directly without any coding.
The cells will need some kind of identifier so you can identify those in your model. A TableView and Core Data can interact with each other pretty well by using the NSFetchedResultsController. Create a simple window based app with a template and check the Use Core Data for Storage. The rootViewController illustrates how a tableView works together with Core Data. For your case it will be getting a bit more complicated as inserting a row will have to determine what kind of cell it should add.
I think you should look into this and get back with some more specific questions.