iOS Development-Development Summary (vii)

Source: Internet
Author: User

One: Gesture and ScrollView compatibility problem if you add a TableView to the Viewcontroller, it is very annoying to have the TableView scroll up and down first when the slide is returned. by Requiregesturerecognizertofail () This method, we can deal with this problem very well.
If let gestures = Navigationcontroller?. view.gesturerecognizers {for    recognizer in gestures {    if Recognizer.iskindofclass ( Uiscreenedgepangesturerecognizer) {               ScrollView.panGestureRecognizer.requireGestureRecognizerToFail ( Recognizer As! Uiscreenedgepangesturerecognizer)               println ("Require Uiscreenedgepangesturerecognizer to Failed")               break           }       }    }

Second: Universal linkOn WWDC 2015, Apple announced a deep link feature for IOS 9, a so-called universal link, with the video address [seamlessly linked to your App]. While it is not a must-have feature, some attention needs to be drawn.

There are so many confusing and wrong information on the Internet that the WWDC itself does not describe the details. Fortunately, in Hoko we added this feature on our smart links, so we can seamlessly guide users to the APP.

What is a generic link?

It's clear that Apple is pushing APP developers to have a better experience on deep links. All the news revolves around deep link technology. At the same time, Apple has launched a generic link: a convenient way to launch apps via traditional HTTP links, using the same URLs to open websites and apps.

With a unique URL, you can link a specific view to your APP, without the need for a special schema. Imagine Twitter using a generic link, then you're on Twitter. COM click on a link, your IOS device will automatically open this page in Twitter, not when you do not have to go to the normal page. This user experience is smooth and, most importantly, the user will not lose context (skip to the APP and no longer leave empty tags on Safari)

Three: Wkwebview

Wkwebview is the new component introduced by Apple in IOS 8 to give a new high-performance Web View solution to get rid of the old, bulky, and especially memory-intensive problems of the past UIWebView.

Apple's uiwebviewdelegate and UIWebView constitute 14 classes and 3 protocols, introducing a number of new functions and interfaces, which can be seen to some extent as compensation for Apple's actions to block the Web View kernel: Since you all say that UIWebView is too Slag, then I'll build a non-slag for you to use Bai ~ ~ as we all know, even Chrome's IOS version is also UIWebView kernel.

Wkwebview has the following major advances:

    1. Extracting the browser kernel rendering process from the APP is managed centrally by the system, which reduces a significant portion of the performance penalty.

    2. JS can be directly used to inject JS runtime JS interface to the Native layer transfer value, no longer through the painful iframe Manufacturing page refresh and then resolve the strange way of custom protocol.

    3. Supports a scrolling refresh rate of up to a maximum of FPS with a built-in gesture detection.

Use of try in swift

In both of these usages, the errors are discarded. If you do not discard it, you can:

if (! ( Value = [instance Request:blah Witherror:&error])  {     ... print error and Return/die ...}

Or

If let value = instance.request (Blah, error:&error) {    ... success:} else {    ... print error and Return/die ...}

Or

Do {let     value = Try Instance.request (Blah)} catch {... print error and Return/die ...}

The system you work with will automatically classify the error value as nil. Therefore, you will get:

    • Swift's nullable optional type and its error system can interoperate. For example, you can write a throwing function and implement it with If-let.

    • The success or failure of a function call is focused on the error report that is assumed by the context of the invocation. "I tried to do X, but it failed", and the traditional mistake was to describe what went wrong, but now it describes what you were doing.

What you have lost:

    • Cocoa-style error handling. Any errors will be ignored and you will not see or know them.

    • Error source information such as file/program-produced problems. You know that the call stack is wrong, but I don't know why.

    • Railway/freight train-style Development mode, as Jeremy Tregunna said, "as a list of input and output code, the left side generates error messages, the right to generate a successful value; bound functions and operators, automatically find all the errors from the call stack ”。

Four: Nsproxy
    • 1:nsproxy is a virtual base class that defines a set of APIs for objects that behave like other object aliases or that do not exist. In general, the message sent to the agent is forwarded to a real object or the agent itself load (or convert itself) to a real object. The base class of nsproxy can be used to transparently forward messages or lazy initialization of expensive objects.
    • 2:nsproxy's message forwarding mechanism can be used to replace multiple inheritance in C + +
    • 3:nsproxy implements the basic methods required to include the NSObject protocol in the Beinecke class, but as a virtual base class there is no way to initialize it. It receives any method that it does not define. He will produce an exception, so an actual subclass must provide an initialization method or create a method, and overload forwardinvocation: Methods and Methodsignatureforselector: method to handle messages that you do not implement. A subclass of Forwardinvocation: implementations should take all measures to handle invocation, such as forwarding network messages, or loading a real object, and forwarding invocation to him. Methodsignatureforselector: You need to provide parameter type information for a given message, the implementation of the subclass should be able to determine the type of argument he should forward the message to, and construct the corresponding Nsmethodsignature object. Detailed information can be viewed Nsdistantobject, nsinvocation, and Nsmethodsignature type description
V: @synthesize, @dynamic the description in the SDK is that when declaring the property, there are 2 choices
    • 1: Tells the compiler to generate the Getter/setter method during compilation by using the @synthesize directive.
    • 2: Implement the method by @dynamic instructions.
some accesses are created dynamically at run time, such as those used by the Nsmanagedobject class in CoreData. If you want to declare and use attributes in these cases, but to avoid missing methods at compile-time warnings, you can use the @dynamic dynamic instruction instead of the @synthesize composition directive . OBJECTIVE-C 2.0 adds the @dynamic directive, which represents the property accessor method of the variable, is dynamically implemented such as: for the height in the interface using the @dynamic directive in the implementation class, and immediately thereafter, You need to specify a function or other class method as the setter of the height, the runtime implementation of the Getter method familiar with the OBJECT-C syntax know @synthesize the actual meaning is to automatically generate the property setter and getter method. @dynamic is to tell the compiler that the code is decorated with @dynamic properties, and that the getter and setter methods are dynamically bound when the program runs or in other ways, so that the compiler can compile. Application:
    • 1: On the property declaration of the Nsmanagerobject object, the core data framework generates getter and setter methods for such properties when the program runs, because the properties of such objects are typically generated from the properties of the core data.
    • 2:category cannot theoretically add variables, but you can use @dynamic to compensate for this deficiency

iOS Development-Development Summary (vii)

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.