how to access objectAtIndex:indexpath.row xcode? - row

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:
(NSInteger)component {
if(thePickerView == self.countryPicker){
self.countryLbl.text = [self.responseArray objectAtIndex:row];
}
}
- (IBAction)countryDoneBtn:(id)sender {
// Picker first row selected on done button
[self.countryLbl setText:[NSString stringWithFormat:#"%#", [self.responseArray
objectAtIndex:[self.countryPicker selectedRowInComponent:0]]]];
[self myViewDown:self.countryView];
[self.durationView removeFromSuperview];
//[post selectState:[self.responseArray objectAtIndex:row ]];
}
i want to do this "[post selectState:[self.responseArray objectAtIndex:row]];"
but can't access "objectAtIndex:row" here in this "- (IBAction)countryDoneBtn:(id)sender"
method.
Please friend help me how can i access the row from this IBAction
Thanks in advance need your help i'm new in iphone development

The row variable is not available because the row you are looking for is only passed in the delegate method didSelectRow:inComponent of the picker view.
Based on you are trying to do, you can still get the selected row of the picker with the method selectedRowInComponent, which you have already used to set the text of the countryLbl.
So, just use the same method to get the object from your responseArray:
NSInteger selectedRow = [self.countryPicker selectedRowInComponent:0];
[post selectState:[self.responseArray objectAtIndex:selectedRow]];

Related

Simple relative cell referencing in google code

I have made this virtual inventory with buttons that copy and paste values to various sheets for different types of reports. The code might not be optimal I am not much of a programmer but I'm trying my best. now I have the same button in multiple places and I want it to copy values in cells relative to the position of the button itself but I am not sure how to reference a cell in a relative manner in the getRange fucntion.
here is the code:
function Go() {
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var sheet = SpreadsheetApp.getActiveSheet();
var destSheet = ss.getSheetByName("Fiche");
var lastRow = destSheet.getLastRow();
var source = ss.getRange ('(rowid-3)(colid)');
var checkbox = sheet.getRange (3,3);
var destColumn = ss.getRange ('B10').getValues ();
source.copyTo(destSheet.getRange(lastRow + 1,1), {contentsOnly: true});
if (checkbox.getValue() == 'vrai' ) {
var source = ss.getRange ('B9');
source.copyTo(destSheet.getRange(lastRow + 1, destColumn), {contentsOnly: true});
source.copyTo(destSheet.getRange(lastRow + 1, 2), {contentsOnly: true});
}
else {
var nombre = ss.getRange ('D5').getValues() ;
destSheet.getRange(lastRow + 1, destColumn).setValue(nombre);
destSheet.getRange(lastRow + 1, 2).setValue(nombre)
}
I want all (B10),(B9), etc. format cells to be replaced with relative cell positons. I have tried with (colID)(rowID) but it doesn't seem to work
I believe your goal as follows.
You want to retrieve the cell coordinate when a button on Spreadsheet is clicked.
Modification points:
Unfortunately, in the current stage, when a button on Spreadsheet is clicked, there are no methods for directly retrieving the information where button is clicked.
So when you want to use the button on Spreadsheet, if you want to retrieve the information, it is required to prepare each script for each button. But I thought that this might be different from the direction you expect.
In this answer, in order to retrieve the information where the button is clicked, I would like to propose the following 2 patterns as the workarounds. In these patterns, the event object is used. By this, the information of the button can be retrieved. This is used.
Pattern 1:
In this pattern, a cell is used as the button using the simple trigger of OnSelectionChange. When the cell "B3" is used as the button like above image, the script is as follows.
Sample script:
In this script, for example, when you want to use the cell "B3" of "Sheet1" as the button, please set "B3" to buttonRanges. And, set sheet.getSheetName() != "Sheet1". When when you want to use the cell "B3" and "B4" as the button, please set "B3" and "B4" to buttonRanges.
function onSelectionChange(e) {
const range = e.range;
const sheet = range.getSheet();
const buttonRanges = ["B3"];
if (sheet.getSheetName() != "Sheet1" || !buttonRanges.includes(range.getA1Notation())) return;
const row = range.getRow(); // This is the row number.
const column = range.getColumn(); // This is the column number.
}
In this case, when the cell "B3" is clicked, this script is run. And row and column are the row and column number of the cell.
Because the cell is used as the button, you can put the value to the cell.
Pattern 2:
In this pattern, a checkbox is used as the button using the OnEdit trigger. When the cell "B3" is used as the button like above image, the script is as follows.
Sample script:
In this script, for example, when you want to use the cell "B3" of "Sheet1" as the button, please set "B3" to buttonRanges. And, set sheet.getSheetName() != "Sheet1". When when you want to use the cell "B3" and "B4" as the button, please set "B3" and "B4" to buttonRanges.
function onEdit(e) {
const range = e.range;
const sheet = range.getSheet();
const buttonRanges = ["B3"];
if (sheet.getSheetName() != "Sheet1" || !buttonRanges.includes(range.getA1Notation()) || !range.isChecked()) return;
const row = range.getRow(); // This is the row number.
const column = range.getColumn(); // This is the column number.
}
In this case, when the checkbox is checked, the script is run. When the checkbox is unchecked, the script is not run.
Because the checkbox is used as the button, you cannot see the text in the cell.
References:
Simple Triggers
Event Objects
Related question
Button change text display every after click
This question is for achieving the switching button.

Flash Builder 4.6 scrollToIndex not working for me

I need to be able to select an index and have it visible. I can get the index to be selected but can't get it to scroll...
for (var _index:int=0; _index < registrarsAll.length; _index++) {
registrarsList.addItemAt(registrarsAll[_index].name, registrarsList.length);
registrarsIDs.addItemAt(registrarsAll[_index].id, registrarsIDs.length)
if(registrarsAll[_index].id == judgeID) {
judgesLB.selectedIndex = registrarsIDs.length-1;
}
}
judgesLB.scrollToIndex(judgesLB.selectedIndex);
The index gets selected but I can't get it to scroll into view. I am calling this on creationComplete. registrarsList is the data source for the list judgesLB.
thanks for any help.
John
I was able to get it to work in the updateComplete event of the judgesLB list...
updateComplete = "{((judgesLB.selectedIndex>13)?judgesLB.scrollToIndex(judgesLB.selectedIndex):null)}"
selectedIndex cannot be negative. -1 will generate an error.

cocos2d creating dynamic menu lists

How do I create a CCMenuItem list dynamically?
//Returns me an array with my items
Items *items = [ItemParser loadItemsForLevel:selectedLevel fromSuperLevel:selectedSuperLevel];
For an item I have a string with the name of the item that I'd like to display in my CCMenu. The number of items could vary but I want to display only 6 items at a time
and how do I remove it? I'm cleaning up from the CCLayer but I'd like to do it also from the menu list
Anyone?
Cocos2D does not provide a method to do this.
You may create your own initializer based on the original one found in "CCMenu.m".
The original looks like this (I removed code that does not add items here for clarity). Create your own init method based on the original and add a variable amount of items instead. If you like you may also set it up as a category to CCMenu.
-(id) initWithItems: (CCMenuItem*) item vaList: (va_list) args
{
if( (self=[super init]) ) {
// ... code cut for clarity
if (item) {
[self addChild: item z:z];
CCMenuItem *i = va_arg(args, CCMenuItem*);
while(i) {
z++;
[self addChild: i z:z];
i = va_arg(args, CCMenuItem*);
}
}
// ... code cut for clarity
}
return self;
}
Update:
When your menu items change then rebuild the whole menu.

How do I add a ComboBox to a TreeView column?

In Gtkmm, I want to have a Gtk TreeView with a ListStore, and have one of the columns in the list be a ComboBoxText. But I can't seem to figure out how to do it.
What I currently have looks like:
class PlayerListColumns : public Gtk::TreeModelColumnRecord
{
public:
PlayerListColumns()
{ add(name); add(team);}
TreeModelColumn<string> name;
TreeModelColumn<ComboBoxText*> team;
}
Then when setting the TreeView (the player_list_view object)
PlayerListColumns *columns = new PlayerListColumns();
Glib::RefPtr<ListStore> refListStore = ListStore::create(*columns);
player_list_view->set_model(refListStore);
ComboBoxText *box = manage(new ComboBoxText());
box->append("Blah");
box->append("Blah");
box->append("Blah");
TreeModel::Row row = *(refListStore->append());
row[columns->name] = "My Name";
row[columns->team] = box;
The column "name" shows up just fine, but no ComboBox. I'm almost positive that simply having a pointer to a combo box as the column type is wrong, but i don't know how it's supposed to go. I do get GTK warning:
GLib-GObject-WARNING **: unable to set property text' of typegchararray' from value of type `GtkComboBoxText'
Which seems to indicate (from a small bit of Googling) that there isn't a default renderer for non-basic types. But I haven't been able to find any examples of how to set one up, if that were the problem. All the tutorials only show TreeViews with primitive data types.
Anyone know how to put a ComboBox into a TreeView?
Okay, I haven't gotten it working 100%, but this example class should get you on the right track:
http://svn.gnome.org/svn/gtkmm-documentation/trunk/examples/book/treeview/combo_renderer/
Basically you need to add a Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > to your columns class and a Gtk::TreeModelColumn<string> to hold the selected data.
Then, to make a column a combobox, you have to add:
//manually created column for the tree view
Gtk::TreeViewColumn* pCol = Gtk::manage(new Gtk::TreeViewColumn("Choose"));
//the combobox cell renderer
Gtk::CellRendererCombo* comboCell = Gtk::manage(new Gtk::CellRendererCombo);
//pack the cell renderer into the column
pCol->pack_start(*comboCell);
//append the column to the tree view
treeView->append_column(*pCol);
//this sets the properties of the combobox and cell
//my gtkmm seems to be set for Glibmm properties
#ifdef GLIBMM_PROPERTIES_ENABLED
pCol->add_attribute(comboCell->property_text(), columns->team);
//this is needed because you can't use the ComboBoxText shortcut
// you have to create a liststore and fill it with your strings separately
// from your main model
pCol->add_attribute(comboCell->property_model(), columns->teams);
comboCell->property_text_column() = 0;
comboCell->property_editable() = true;
#else
pCol->add_attribute(*comboCell, "text", columns->team);
pCol->add_attribute(*comboCell, "model", columns->teams);
comboCell->set_property(text_column:, 0);
comboCell->set_property("editable", true);
#endif
//connect a signal so you can set the selected option back into the model
//you can just have a column that is not added to the view if you want
comboCell->signal_edited()
.connect(sigc::mem_fun(*this,&ComboWindow::on_combo_choice_changed));
EDIT ABOVE
I think something along the lines of using a Gtk::CellRendererCombo* is the way to go in your PlayerListColumns
http://developer.gnome.org/gtkmm/stable/classGtk_1_1CellRendererCombo.html
(I haven't made a working test yet, but I got the idea from:
http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview.html.en#treeview-cellrenderer-details)

how to implement Action in sectionIndexTitlesForTableView Delegate method.?

Hi friends i want know sectionIndexTitlesForTableView Action is works
i have the following code... but i want to call the web services with A/B/C/D.... Z as parameter.. So i need to know how it is?
My actual need is the products list in with starting letter As A in default , when click on B then i want to show the Product list with Starting letter as B. And also i want A.to..Z in the Right side for table view for select the letter... so i tried this but i dont know how to give the Action so please help me..
selectArray = [[NSMutableArray alloc] initWithObjects:#"A",#"B",#"C",#"D",#"E",nil];
Method is:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return selectedArray;
}
I solved my Question as shown below
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
if (title) {
[self webCall:title];
[tableData setArray:nil];
[table reloadData];
}
return 1;
}