Diary for iOS development




[5] Diary for iOS development

We continue to tell you about the progress of the process of developing an updated version of the application for iOS AppleInsider.ru 7. Narration is personally CEO studio Unreal Mojo Thank Karpenko, so interesting and informative read guaranteed. Today we offer you the next entry of the diary.

Day 6

Or rather, “the sixth episode”

The last time stopped on that more or less did the overall operation of the table news, even rewriting the mapping process of the bubble with the number of comments. The next day discovered that lightly screwed on calculated widths of the bubble itself – in the formula instead of plus minus set in the result, the “wider” was the number, the narrower the vial was obtained. Corrected.

Next, connect the notification of changes in the state of objects that the table is properly updated, for example, when you read an article, or when changing a number of comments to the article.

Since the first two versions of the application server work differently, often creating unnecessary strain, and especially because of the annoying limitations of architecture with the server if the application from starting a few days, had a chance to miss a few articles that came out at the time that you do not run, methodology of work with server-side API, it was decided to change.

Earlier (AppleInsider.ru 1.x and 2.x) server application requests a list of recently published articles with all the attributes (title, author, date, number of comments, a link to the article, a link to the picture and yet all different cloud) . In addition, it ate extra traffic for users and it has generated a lot of excess traffic at the server. Because in version 3 application, it was decided to do differently: now it requires only a list of identifiers of articles with a publication date, and then only if no other data base for each of the required items, ask the server about the data needed for specific articles. To minimize the load on the server (and we remember that the application used by tens of thousands of people every day), such requests are also grouped application packet and sent all requests for information about the article for last second going into a pile, and sent to the server.

Based on these considerations, wrote system that has accumulated the request and asks the server. Since different application modules can theoretically request different pieces of information about the article, it was necessary to implement more logic grouping queries on types of information:

typedef enum {kPostInfo_Title = (1L << 1), kPostInfo_CommentCount = (1L << 2), kPostInfo_PostBody = (1L << 3), kPostInfo_Thumbnail = (1L << 4), kPostInfo_Slug = (1L << 5), kPostInfo_URL = (1L << 6), kPostInfo_Date = (1L << 7), kPostInfo_Metadata = (kPostInfo_Title | kPostInfo_CommentCount | kPostInfo_Thumbnail | kPostInfo_Slug | kPostInfo_URL | kPostInfo_Date) } PostInfoMask; Deciding for a few hours and the problem data ottestirovovav work svezhenapisannogo code passed to the next task: displaying images to articles. AppleInsider.ru for iOS 7 To store pictures, it was decided to use FastImageCache from Path. The decision was made for many reasons: to store all the downloaded images on disk as separate. Jpg files, as was done in previous versions - very expensive in terms of performance, as a result, when the user was shaking up and down the list of news per cell had to download the file from disk, decompress it (aka JPEG) and only after this draw. Of course, a number of optimizations and was in previous versions, but that offer children from Path, I generally liked. Leaving aside the fact that I did very well belong to the Path, as their co-founder Dustin Mierau once began his programming career in my first company, helping to develop the player MacAmp. Somewhere for an hour in the integrated library code at the same time immediately write code that would cut through UIBezierPath your image in a circle, as in design. Then connected to the network manager code that requests pictures through the second NSURLSession (low priority execution) and everything magically earned: AppleInsider.ru for iOS 7 Along the way, found the problem - Titles of articles found HTML entities like "- as in the screenshot above in the article about the" CEO ". Added code that translates them into normal UTF-8 (with a piece GoogleToolboxMac). At the same time found that the server all "small" pictures for the articles are stored in a not quite so small - often under 100 kilobytes in size somewhere and 650 pixels in width (when the application needs a maximum of 140). Application, of course, after downloading the picture cuts in the required form, but the extra traffic like as too is not needed. Consulted with the guys who are engaged for AppleInsider.ru server side, they will try to compress such images on the server in the future. It is encouraging that the application for this remake will not need ☺ In this work to create a list of news can be considered more or less complete. For it will do: Search - I'll do this later CS is a social network - that I'll get too later, after the controller will do for viewing text news, which will need the same sharinga Switch top news - Favorites - Categories. Do it immediately after viewing text news Implement display advertising banners. It's time to implement the next controller that directly shows the news: AppleInsider.ru for iOS 7 As in previous versions, it is essentially a wrapper over UIWebView, as the text of the article comes to us in HTML. From conventional browser controller has a very complex logic with the contents of the article. Took from the old version code that inserts text in the template HTML, which is then displayed in the web view. Of course, the HTML and styles had to undermine that was similar to that painted designer (something he certainly nafantaziroval such that I can not do it, but without it is never complete, because you always have to look for reasonable compromises or ignore the mega-ideas 😉 . When the user when reading article concerns pictures or links, then switched moderately branched algorithm checks that should be done: If it is a picture, you need to show it in a separate controller on the entire screen; If this is a reference to a certain web page, you need to understand this external link or a link to an article on AppleInsider.ru; If an external link, then see if it is allowed to open without the user questions about whether he wants to go to it (there is some set of rules by which clear, ask or not ask); If an internal link, then see if it is a link to an article with the "letter" name (for example, http://appleinsider.ru/sluxi/sluxi-evad3rs-prodalis-kitajcam-za-million-dollarov.html - it such "literal" part is «sluxi-evad3rs-prodalis-kitajcam-za-million-dollarov»). Do a search on the basis of their own in search of this tag for articles (suddenly it does not need to download). If nothing is found, then ask the server about what ID belongs article with this title, and then load the data and show the new controller with this article; If an internal link, but kind http://appleinsider.ru/?p=241842, then get out of the reference identifier (241842), then look for it in its own database, if not, ask the server about it, then upload the data and also show article. Gathered partially rewrote the code and voila! Then became implement logic referrals to the article and found that the server broke down and does not return the required data (a common thing for any project that interacts with any server). While the guys out there understand, I'll do other things, good enough work.


In: Technology & Gadgets Asked By: [15576 Red Star Level]

Comments are closed.

Answer this Question

You must be Logged In to post an Answer.

Not a member yet? Sign Up Now »