views:

49

answers:

1

Hi everybody,

I have the following php script that allows me perform some calls to other php pages. I have a "data" array that contains a set of "id"s and a "name"s.

So the "$data[5][0]" will correspond to the "id" column of the sixth row and "$data[5][1]" will correspond to the "name" column of the sixth row.

If I execute this script (this is just a sample, it may not work), It will display a list of "names" with a link that will permorf the delete action:

for (i=0;i<sizeof($data);i++)
$var .= $data[$i][1]."<a href='http://remote.com/call/delete.php?id='".$data[$i][0]."'&gt;delete&lt;/a&gt;&lt;br/&gt;";

And of course, in the "delete.php" script, a mysql function will execute an sql statement based on the given "id" in the url.

Now, I'd like to translate the same script (the loop above) into objective-C.

I can list the items in a Data View. But I can't put in place a solution that can "hide" the id in a table cell and when the user clicks on that cell, I can get the hidden "id" and then call the "delete.php" script.

Did anyone try to do so?

Thank you,

Regards.

A: 

You can subclass UITableViewCell to add whatever stuff you need (like your record id and name), so when you create them in tableView:cellForRowAtIndexPath: of your UITableView delegate you can fetch the id and name for the row and set the corresponding UITableViewCell's subclass as needed.

Then you can add gesture recognizer to that UITableViewCell subclass and when the user taps it or swipes or whatever, you can do the delete.

SVD
Do you have a piece of code that shows how can I create a subclass and use it in the UI?
Zakaria
E.g. http://icodeblog.com/2008/09/02/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-2/ - see the Create a UITableViewCell Subclass section
SVD