You could add Action<MyRowClass> as an ivar of your table source. When you 
create your table source set that ivar to a corresponding method or lambda in 
your edit dialog thingy. Instead of show alert, you would do (ivar 
name)(selected row) to fire the action on your edit dialog. 

A more IOSish way would be to create an interface (protocol) for your table 
source, co taint a method like "ContactWasSelected(MyRowClass contact)", 
implement the interface in your editor, make an ivar in your table source for 
the interface and proceed as in the previous example. 

If you like tight coupling, make an ivar of type "my Editor class" in your 
table source and set it to the instance of your editor. Call methods on the 
class directly. 

If what you mean about "because its a class" is that you don't have an editor 
instance lying around, just pick one of the above strategies only tie it to a 
method on your listviewcontroller and have that controller create and present 
the editor interface. 

Lots of ways to attack your problem - I'd probably go with the Action<> method 
for the sake of expediency. Delegate/protocol/interface is good if your table 
source needs to call back for more than one thing. 

Sent from my iPad

On Jun 4, 2011, at 10:26, John Murray <[email protected]> wrote:

> I’ve pretty much managed to convert an Android app into  monotouch but I am 
> completely stuffed on this one= I am really desperate
> 
> Clearly having a senior moment
> 
> It’s probably the way I’ve constructed my code and having a tendency to 
> functional programming J
> 
>  
> 
> I’ve got a viewcontroller and view (actually one of s series of tabs) – on 
> this there is simply a button (add persons) and a table crewTable
> 
>  
> 
> I’ve implemented my own tablesource as per tutorials
> 
> User presses ‘Add Person’  subview added and lots of detail is then added for 
> that name
> 
> Press save on nav bar – the Edi Dialog disappears and the name alone is added 
> to the TableSource
> 
> So far so good
> 
>  
> 
> If the user taps on a row in the table – Alert comes up and displays what was 
> selected
> 
> This takes place in the tablesource.rowselected method
> 
>  
> 
> What I want is to present user with choice to edit or delete the item
> 
> The table item is a name – that’s all thats displayed in the tableview – but 
> there is a public class holding a load more info which was created in a 
> dialog view
> 
> What I want is to get back from the table view the row – that’s all but I 
> just cant see how to do it – the rowselected is a void and I cant understand 
> how to trap the user tap in the main code
> 
> -          Example
> 
> -          List<string>cl = new List<string>();
> 
> -          Cl = myCrew.getcrewlist();
> 
> -          myTableViewSource clist = myTableViewSource(cl);
> 
> -          crewTable.Source= clist;
> 
>  
> 
> //===========above code is in finished launching where all my controls 
> created in IB are visible
> 
>  
> 
> // a snippet of myTableViewSource
> 
>  
> 
> public  class myTableViewSource :UITableViewSource
> 
> {  
> 
> private List<string> rows;
> 
>     public MyTableViewSource(List<string> list)
> 
>        {  rows= list;
> 
>        }
> 
> //========other methods
> 
> // === such as rows in section
> 
> // ====get cell  
> 
>  
> 
> Public  override  void  RowSelected(UITableView tableview,NSIndexPath 
> indexpath)
> 
> {
> 
>    ShowAlert(“row selected ”,”you selected ”+rows[indexPath.Row].tostring());
> 
> }
> 
> //=======
> 
>  
> 
> Great, the show alert works but  I can’t put anything into the 
> myTableViewSource.RowSelected method which references the EditDialog in my 
> main code because it is a class and EditDialog is not visible at this level 
> and therefore I can’t fire up the EditDialog on this touch event  even though 
> I can fire a showalert
> 
>  
> 
> In the main view which contains the table there is an ‘add person’ button 
> which when  clicked – it pulls up this EditDialog view – when that is saved 
> the data is saved and the new name is added to the crewTable and the 
> EditDialog is dismissed.
> 
> What I want is to intercept the event which happens in the rowselected method 
> of the tablesource class – as above and does the showalert() but to recall 
> the EditDialog this time populated with the relevant selected persons data
> 
>  
> 
> I am sure there is a straightforward was but I’ve trawled everywhere and I 
> cannot find anything helpful all the examples seem to stop at flashing up a 
> messagebox or something
> 
>  
> 
> I would be really grateful for some help even if I am being stupid here
> 
>  
> 
> Tia
> 
> John Murray  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to