As you remember, in the last lesson we created the 'Recipe Book' program for iOS. The main disadvantage of that program was that all the data was static, and in order to update it, it was necessary to add the application code and send it for re-moderation in the AppStore. Today's lesson will show you how this problem can be solved. It should be noted right away that for this tutorial you must have a web server with Internet access. All of the examples in this tutorial series will be written in PHP, so your server must be Apache or ngnix based.
The main purpose of the application that we will write is to display site news from a MySQL database table.
Most news sites use a SQL database, but it's worth noting that our application will not make a direct SQL query against the table because there is no corresponding framework in Xcode. But Apple made it possible to form arrays from a JSON file. Therefore, we will write our own API that will generate this file. Namely, we will make a PHP script that will make an SQL query and then automatically generate a dynamic file with a JSON structure. Of course, you can use XML format as well, but practice shows that then the program will process the result much slower.
As you probably know, all news sites have their own CMS (content management system), while many use the so-called 'open' CMS – WordPress, Joomla, Drupal, etc. Since the partner of our channel is the LWTS group, we will analyze the creation of a news parser based on their CMS, which you can download from this link – http://loutskiy.ru/products/1. However, it will not be difficult for a web developer to convert this script for other engines.
interesting 6.1-inch iPhone 12 and iPhone 12 Pros to go on sale first Eighth beta versions released iOS 14 and iPadOS 14 for developers and public testers
So, our program will receive and display news as a list, through the UITableView table, and by clicking on a cell, open a page with the full text of the article. If everything is clear with the list of news, then the full text of the news will work as follows: a page with a UIWebView will open, which, in turn, will load a dynamic PHP page with the text of the news.
So, to start studying the lesson, you need to download our library, which consists of an Objective-C class and PHP files that generate a JSON page and a file with news text.
VIDEO
In the next lesson, we will analyze how to organize the display of comments to articles in the application.
Download parser and class files Download project sources
In order not to miss anything, subscribe to my YouTube channel.