My environment:
Mac OS X v 10.10.4
Version 6.4 (6E35b)
My Project:
Mac app using Swift 1.2 with storyboard
A bit of background: I got an NSTableView with multiple columns all hooked into an NSArrayController, which in turn, is hooked up to core data (say entity "Car"). Everything works well - I can load and edit the column values, and save changes to sqlite. All of this is accomplished with bindings via Interface Builder. I now want to add a new "color" column to this table, representing a relationship to another entity, say entity "Color". Each row will have an NSPopUpButton for this new column; the pop-up button should have its values populated from a second NSArrayController linked to the "Color" entity. Thus, "color" is a many-to-one relationship between Car and Color (many Cars can reference a given Color), and I'd like the values in the pop-up button to correspond to the "name" property from Color.
What I've done:
In the storyboard (under the controller scene containing the Car table), I've added a second NSArrayController, "Colors Array Controller":
1) under "Attributes Inspector" -> Mode = Entity Name, Entity Name = Color, "Prepares Content" checkbox selected
2) under "Bindings Inspector" -> Parameters -> Managed Object Context -> "Bind To" checked -> selected "Cars Controller" -> Model Key Path = context
In the Cars table (under NSTableCellView), added an NSPopUpButton.
At this point, everything builds and runs properly, except that all the columns in the table show the "Item 1" default value from the pop-up button (I can also see the other default values when I expand the pop-up).
Now, I've tried the following in a futile attempt to load the pop-up with the correct values:
Strategy 1:
using Interface Builder, selected the NSPopUpButton. Under Bindings Inspector (Value Selection), checked "Bind to" and specified the Colors Array Controller from above; Controller Key -> arrangedObjects; Model Key Path -> name
Strategy 2:
created an IBOutlet, "colorsArray", for "Colors Array Controller" in Cars Controller;
using Interface Builder, selected the NSPopUpButton. Under Bindings Inspector (Value Selection), checked "Bind to" and specified Cars Controller; Model Key Path -> colorsArray.arrangedObjects
For both of the strategies above, whenever I try to run (or just build) the project, Xcode hangs at "Compiling 1 of 1 Storyboard files". Activity Monitor shows that the "ibtoold" process steadily consumes all memory available (as soon as I kill it, Xcode reports my build as failed).
I would really appreciate if somebody could shed some light into what I'm doing wrong, or suggest alternatives to achieve the desired results.
I just ran into the same issue: As soon as I bind a NSPopupButton's content binding to an ArrayController's arrangedObjects Xcode will compile the storyboard forever. When I remove the binding it will compile as usual :(
Since my NSPopupButton is inside a table column, I've removed the array controller and I'm now binding its content directly to a property of the table column's object value.
Related
Is there a way to populate a List property on an object being tested under the "new style" test scenario?
I see some "legacy" test cases which seem to achieve this so am wondering if the new style test scenario handles this.
I added the List model to my test case, which enabled me to expand the sub-property on the object, however there is only one field available there, "empty" (boolean). Is there a way to add an object here? If it makes any difference, the model is an external java dependency.
Update
The reason I wasn't able to add the List of objects was because I didn't explicitly import that object dependency into the test. Once you import it you can follow the steps given in the answer below.
It's definitely possible to manage a List property under the Test Scenario Editor.
Please consider the following example: A Book class with a List<String> property named topics.
Creating a new Test Scenario assets, please select the column where you need to add the List property, and in the right part of the editor select the property expanding the Book class, as shown below:
Pressing Insert Data Ojbect button will assign the selected List property to the selected column:
To fill the data in the List property, please double click on the Insert value cell, in the first scenario data row. A popup will appear. Its aim is to fill data inside a collection
To add a value, please press the Add list value link in the bottom part of the popup. Here, you'll be able to fill a single item on the list
Repeat this step for all the items you need to add to the list. When completed, simply press to Save button
The popup will close and you should see the previously selected data cell filled with a label similar to List(2), the number represents the number of the items in the list.
The problem:
You wanna contribute to the some gnome/gtk/gtkmm project since you've noticed and know a way that things could be made better / you wanna fix some bug. Here are steps to get you started.
Example problem:
"Clean" button in Gnome Builder isn't doing anything to my project and since at this point I believe it is just empty function with placeholder button I wanna implement actual action.
Here are steps:
open application that you wanna modify in terminal where environment GTK_DEBUG=interactive environment variable is set. so run GTK_DEBUG=interactive gnome-builder
Gtk inspector should have opened and you should see bunch of Objects displayed. If you click on Object in inspector, that object should light up in your application
Gtk has clear hierarchy, so parent contains children, and your job is to detect in which parent is child that you want to modify
When you figure which parent you want click on arrow next to the name of that parent to reveal its children
Repeat steps 3. and 4. by applying 2. to get to the child that you want to modify
For example my path is IdePrimaryWorkspace -> GtkPopover -> GtkBox -> DzlPriorityBox -> GbpBuilduiOmniBarSection -> GtkBox -> GtkBox -> GtkButton
Double click last interactive entry (such as GtkButton
on the left, in drop-down switch to Properties view
find property that you want, mine is GtkActionable, and it's value is builder-manager.clean
open source folder in terminal of application that you are interested in (clone source of that application)
type in command tree | grep build-manager
if there are entries with that filename type in find . --name=filenameof.your.file
get file path, open that file in text editor/IDE, change stuff inside
submit patches
First — I even don't know how to describe this problem. I will start from the beginning.
I have a NSTableView with Managed Objects Invoice objects. Invoice has client, date... I can access to them by invoice.client in cells. OK. Works. When I double click on row, next widow with details of selected Invoice opens. It' done by binding Double Click Argument and Double Click Target. I'm passing selectedObjects to method, method loads nib, makes widndow and voila. In NSViewController subclass I have
#objc var invoice : Invoice? {
didSet {print ("Set Invoice \(invoice?.description ?? "no invoice")")}
}
and it prints Invoice. It is set.
And now is a puzzle. If I try to bind ANY UI object (label to invoice.date, invoice.client.name etc..)
window does not pop after double-click and I got an error:
2019-08-31 22:13:45.252956+0200 fakturaVatParser[11444:12617343] [General] [<__NSSingleObjectArrayI 0x60000004e180> addObserver:forKeyPath:options:context:] is not supported. Key path: client
Not only client... every relationship and attribute of Invoice. The same paths which works perfectly in NSTabView cells.
Any ideas?
I have a view (created in a StoryBoard) that has a couple of NSTextFields and a slider control. I have one NSTextField that that takes the value of the another NSTextField and a sliderValue.
When I click the "Add" button (which is connected to the add: action of the array controller) all the values are added...except the value in the NSTextField with the "computed value". I can type in that field manually, and it works. Have looked on this site, apple documentation, and general google searches, but I'm not sure why I cannot add this data to the array controller. More details (code)...
NSTextField: Name **Gets added**
SliderValue: Grade **Gets added**
NSTextField: gradebookName **Only adds if manually typed in**
Code:
var txtGradeBookName: String
let sliderValueString = String(sender.integerValue)
txtGradeBookName = txtName.stringValue + "GradeBook" + sliderValueString
gradebookName.stringValue = txtGradeBookName
The ArrayController is bound to a Core Data model. Again, txtName and the Slider value gets added no problem...but gradebookName never gets added (unless I manually type it in)...and it's binding is set up identical to the the other two.
I'm creating a coffee timer as a learning exercise and I want to have a different menu based on the brewing method selected. I'm storing my settings in NSUserDefaults and populating my tables with two separate arrays that look like this:
var aero = ([
"Cool Down Time Enabled" : true,
"Cool Down Time" : 30,
"Inverted" : true,
"Base Steep Time" : 150,
"Base Inverted Steep Time" : 180,
])
var french = ([
"Cool Down Time Enabled" : true,
"Cool Down Time" : 30,
"Base Steep Time" : 180,
])
I created two UITableViewControllers, one for FrenchPress and one for AeroPress, they are largely the same code:
FrenchPressTableViewController.swift - settings menu
AeroPressTableViewController.swift - settings menu
Both assign values to instances of my Setting.Swift class (gist) and get stored in different arrays.
In IB I started with my french press controller and created two prototype cells and two prototype classes to go along with them.
SwitchCell.Swift - Model for my UISwitch prototype cell outlets
TimingCell.Swift - Models my TimingButton prototype cell outlets
Initial Steps taken:
Create new tableView in IB for my French Press settings.
Create a designated FrenchPressTableViewController, and assign it to my new French Press table view
Set up two new prototype cells and set up IBOutlets/Actions using my SettingCell & TimingCell classes.
The IBOutlets are connected from my FrenchPressTableViewController to my SettingCell.swift (I later reuse these outlets for my Aero settings).
My FrenchPress Settings Works Fine:
So I decided to add my Aero press settings menu using the same process:
Create new tableView in IB
Create a AeroPressTableViewController, and assign it to my new aero table view
Set up two new prototype cells and assign my previously existing SettingCell & TimingCell to the proper cells.
I utilize the outlets that I previously connected to my FrenchPressTableViewController and I connect them to my Aero controller as well to reuse the cell classes.
The final product looks like like this:
But when I run my Aero settings menu, I get the following error:
fatal error: unexpectedly found nil while unwrapping an Optional value
Question:
From what I can tell from my debugger, it looks like my SettingCell class is returning a nil value with cell.switchLabel.text. This doesn't make sense to me since I'm trying to assign a value to it.
Clearly I'm doing something wrong, what is the proper way to reuse my UITableViewCell classes?
This issue arises while registering the UITableViewCell class as tableView.registerClass(SwitchCell.self,forCellReuseIdentifier:"SwitchCell2")
Remove that line tableView.registerClass(SwitchCell.self,forCellReuseIdentifier:"SwitchCell2") and set the cellIdentifier in storyboard..it works