开发者

How can I translate this php script in Objective-C (Cocoa Touch)

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]."'>delete</a><br/>";

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜