NSComboBox value getting and assigning it to a label - objective-c

I am new to Mac development. I want to get the value selected from a combo box and assign it to the text of a label in a Mac app using Objective-C. How can I do this?

Following gives the selected value:
[yourComboBox objectValueOfSelectedItem] returns id. Have a try with following, if in case you may require to type cast it to NSString.
[self.yourLabelOutlet setStringValue:[yourComboBox objectValueOfSelectedItem]];
*Not checked, but something similar to this
EDIT:
Find a Sample Project.

The accepted answer only works when your NSComboBox does not use its own dataSource
When using your own dataSource for your NSComboBox you should approach it like this:
[yourDataSourceArray objectAtIndex:[yourComboBox indexOfSelectedItem]]);

Related

isEmpty doesn't appear in suggestions (Kotlin)

I write to you today because I am developping a code for a quizz application and among the things i want to do is to check if a user fill an empty field text but when i do that in Kotlin : it simply doesn't work and I don't know why. Here is my code :
enter image description here
[1]: https://i.stack.imgur.com/vMY9q.png
Could you help please ?
It's isEmpty(), like a function call - not a property

Ocean SDK get property value at cell

In my plugin I get property as an input parameter. I'm trying to get property value at particular cell. I've checked that value at the cell is really defined, but I get Nan.
Code sample:
double permValueCell;
Index3 TestIndex = new Index3(54,8,7);
permValueCell = _propPermeability[TestIndex];
Firstly I thought that there is some problem in getting property as parameter, but during debug I saw that description section of the property displays a correct name. What can be wrong ?
In Petrel, the cell index seen in the UI is not the same as stored in Ocean.
You can convert between the two by using the ModelingUnitSystem class in Petrel 2014.
Look at :
Slb.Ocean.Petrel.ModelingUnitSystem.ConvertIndexFromUI
Slb.Ocean.Petrel.ModelingUnitSystem.ConvertIndexToUI

Cocoa library for popup with different title from value

I am looking for the best approach to this issue. I have a PopUp Button with 4 entries in it. I would like the user to be able to change them, however when the popup button changes and I access the selected value, it will be my predefined value and not what they customized it to be.
Example
|Value1|
|Value2|
|Value3|
|Value4|
is my predefined. They may change them to
|1Value|
|2Value|
|3Value|
|4Value|
However when they select 3Value I need the code to see Value3.
Is there an already existing library that supports this? If not what would be the best approach to do something like this? This is for a Mac OS X Application.
In NSPopUpButton you will find a property indexOfItem. Just use the index to identify the items.
NSArray *original = // the values of the original items
NSInteger *selected = [popUpButton indexOfItem:popUpButton.selectedItem];
id originalItem = [original objectAtIndex:selected];
I ended up using coredata with a apieKey and displayValue. I then use a fetch request to get the key (original value) when needed.

getting the value of the boundfield in a gridview

I have encountered something strange.
I wanted to have the value of my gridview boundfield so I did this.
SelectedID = objGridView.Rows(0).Cells(4).Text.ToString
At first this seemed to work. I played around a little created a hyperlinkfield wanted to get that value but got an empty string. After some looking around it turned out I could not get it as easily as I could with a boundtextfield. No problem.
But here comes my problem , now all of a sudden my line of code to retrieve the value from the selectedId does not work anymore ( at least I'm getting empty strings back ).
I've build and rebuild my gridview but to no avail.
I'm flabbergasted and don't get it why it doesn't work anymore.
Hence my question.
Does anyone have an idea what's happening or have a solution to this problem.
edit:
I'm seeing this in my item value
"In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user"
Don't know why you dont use the datagridview.
I started with GridView as well but after changing the control type it's really easy to get those values e.g:
SelectedID = dgvExample.CurrentRow.Cells("Columname/Index").Value
dgv compared with gv
There is an answer here
An other one (which was the reason of my problem) could be that the BoundFields are set to Visible = false. Invisible Bound fields are... not bound.
A simple workaround is to make it invisible in CSS instead.
Code behind :
gvColumn.ItemStyle.CssClass = "className"
CSS :
.className { display:none; }

Finding curCapacity and maxCapacity Value, iPhone

A method which can be used for finding the battery percentage of your device is found here:
http://blog.coriolis.ch/2009/02/14/reading-the-battery-level-programmatically/comment-page-1/#comment-6085
I have tried it and it works great. If you have a closer look at the code there are two values curCapacity and maxCapacity. I want to be able to use these values in other calculations, yet when I try and do this I always get the error 'undeclared'.
Any ideas as to why?
where are you trying to use this variables? they are declared inside - (double) batteryLevel method so you cannot use them in other methods. if you want to use them in other places, declare them in your .h file. so you will be able to get access to these values not only from this method.