I am trying to create a UITableView that lists each teacher in my school and acts as a link to each teacher’s web page.
I have taken the HTML code off of the webpage and not have the list of teachers and page URLs.
To ensure privacy, the list code I am showing you is not real and the names and site addresses have been changed. It is an example, but is equivalent to what I am trying to do.
The list code is:
<div class="field-element"> <select name="" class="form-select launcher" id="" ><option value="0">-Select-</option><option value="/subsite/teacher/714">LastName, Firstname</option><option value="/subsite/teacher/286">LastName2, FirstName2</option><option value="/subsite/teacher/734">LastName3, FirstName3</option><option value="/subsite/teacher/513">LastName4, FirstName4</option></select>
with the /subsite/teacher/... code being the teacher page link appended to the URL www.website.com (resulting in www.website.com/subsite/teacher/... and the actual name of the teacher following that URL code in the HTML. This cycle repeats for each teacher.
How can I create an array of each teacher and the corresponding link for a UITableView from that HTML code? The UITableView would display the teacher’s name in the format LastName, FirstName and when that cell is clicked, a UIWebView will open the corresponding web page.
Some example code would be greatly appreciated.
Note: Understand that the number of teachers could fluctuate, so it is not safe to assume the same number of teachers and the same names each time.
Thanks.
The general outline of the code could go this way:
NSStringclass and probably using thecomponentSeparatedByString:.UITableViewand populate it. Consider on the development of your model that you should not only include the name of the teacher but also the web-site as a property of that object.didSelectRowAtIndexPath:method to respond to each cell by pushing aUIWebViewinitialized at the site corresponding to the teacher’s website.Hopefully this will help you.