iOS First exercises

Source: Internet
Author: User

Starter: personal blog, update & error correction & reply

The code here, is not familiar with Git, in the new project on GitHub after the thoughtful hint is not to execute such two sentences--

I'm sure I can't carry these two sentences, so just remember.

Git remote add Origin https://github.com/qidafang/iOS_427studio.git
Git push-u Origin Master

The mobile phone version of the App,ios studio has been developed more smoothly than Android, documenting the knowledge used:

1) Presentation layer

The storyboard makes the interface +controller class, with a very comfortable combination. And the base library comes with tag structure and navigation structure.

Interface drag-and-drop generation, the controller of the two key elements (representing the interface element object instance property, the response interface element operation of the instance method) is also dragged and generated.

So simple, so that the controller is too concise, simply let it implement interface elements of the data source interface and proxy interface, in order to implement the corresponding method, the object should be a collection of element data must be a controller instance properties, of course, it is also natural, It is natural for a controller to hold the model.

interface components, the use of the Label button text box is not said, WebView the specified HTML and specify the URL of two different usages.

2) Rest

Because the example is simple, eliminate the business logic layer, directly say the data layer. Of course, the data layer refers not to the narrow "relational database", but to the generalized approach of dealing with all forms of data sources, which is divided into two parts: Rest and DAO, which are used to deal with servers and local databases, respectively.

Because the rest class is used asynchronously in the callback function, and "Follow-up" is to modify the interface, such as fetching data from the server to fill the interface list, so the rest layer class needs to hold the Controller class object, In the callback function, modify the properties of the controller class (that is, the model property that represents the page data), the method that invokes the controller object (such as the reload method that lets the table reload the content).

From a hierarchical point of view, this "lower class to understand the existence of the upper class" is unreasonable, more reasonable should be a controller implementation of an interface such as Restcaller, which defines a function such as Onrestok (Data:nsobject), The method implemented by the controller obtains data from rest and then executes the logic, and the rest class declares a var caller:restcaller instance variable and invokes the Caller.onrestok (useful data) in the callback function. When the Controller class uses the rest class:

Let rest:somerest = Somerest ();

Rest.caller = self;

Rest.doquery (xxxx);

This is a decoupling of ideas, because time is not realized. As for HTTP requests, JSON processing, the use of these basic class libraries is not said.

3) DAO

Although the project is written in Swift, but in DAO this piece still has to use objective-c, let me very happy objective-c study still useful. But other than that, it's not good to have two languages mixed up.

Because of the basic syntax, very similar to the Java JDBC Set, open the connection, prepare SQL, give parameters, execute, traverse the results of what, do not say much. The use of the global function is similar to the use of PHP, object-oriented programmers see, the superiority arises spontaneously.

The sample program is a list of additions and deletions, similar to Android, the list is the base library, the cell implementation, the Cell object needs to hold the data, because in the click of the button to delete the buttons need to know what the point of the line, after the deletion will definitely need to let the controller refresh the data, So let the cell object hold a reference to the controller (it holds the DAO singleton for the sake of convenience). When you open a form page, you need to be sure that the form controller knows that you are adding or changing, and that you have the data for the object you want to change.

4) Summary

With the above 1) 2) 3) The three techniques, integrated use of the "good use of the heart," because it is practiced hand, not the design and encapsulation of metaphysical, such as the refinement of basic classes and interfaces. For small projects, it may be more comfortable to downgrade to a superficial level of abstraction, killing cows by killing sledgehammer, killing chickens and killing chicken knives.

It's like when Servlets and JDBC (plus basic html,css,javascript) will be used, the rest is the icing on the cake, and then the biggest gains in design and thought. And I personally because of the long-term Java training, but do not need to do "spend a lot of time on iOS to practice to progress to the realm of thought" this work (laughter), after all, like "Enterprise Application architecture model" such as the greatness of books, not only in a language and a certain field, fortunately, these books I read (personal book)

This one months or so (total time more than one months, but the net time is not) is not short, is not long, after all, is two languages, several books, a new operating system (Mac bad!). ) and the IDE. Although not long, also ends, because according to love teacher said hybrid development is the mainstream, that iOS native technology understand the foundation, and have the ability to learn other foundation at any time, it is enough, later with mixed development, not confused: "Oops I do not understand iOS native development, mixed development a bit in the dark." ”。

Last Last Picture ~

Long-term welcome project Cooperation Opportunity Introduction, project income 10% to reward introducer. Sina Weibo: @ Cold Mirror, qq:908789432.


iOS First exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.