iOS development--Kinky skills Summary of various sexual techniques in the development of &ios (ii)

Source: Internet
Author: User

Summary of various kinky techniques in iOS development (II.)First, the author of the computer installed on the Mac appOne: Internal implementation (SWIFT) for :
1 var g = array.generate ()2while let     obj = g.next () {34< /c9>5print (obj)}6  


 Two: Map/fileter/reduce
    • Map

Map method, which gets a closure expression as its only parameter. Each element in the array is called once for the closure function and returns the value that the element is mapped to (or a different type of value). The specific mapping method and return value type are specified by the closure.

When supplied to the array closure function, the map method returns a new array containing the mapped values corresponding to the original array one by one.

Definition of Map func map(transform: (T) -> U) -> U[]Over here TAnd Uare generic and refer to a type, TAnd UOnly two different types can also be the same.
Let prices = [ten,A,"¥\ ($)"
The results obtained: print(strPrices) //[¥10, ¥20, ¥30]
    • Filter

Filter, as the name implies, is used to select elements in the array that satisfy the criteria
Definition: filter(includeElement: (T) -> Bool) -> T[]
Accepts an array element to return a bool type

Let p = [ten,A, A, a,a.] Let res = p.filter{$0>  (}
Get results: print(res) //[33, 44, 87]
    • Reduce
The reduce method calculates the combination of array elements as a value and accepts an initial value, which may be different from the set element type. To see the definition. reduce(initial: U, combine: (U, T) -> U) -> U
let P1 = [all,ten] let sum = P1.reduce (0) {$0+$1///  -
Summary: It is necessary to note that when the data is large, higher-order functions are faster than traditional implementations because they can be executed in parallel (as running on multicore), and they can be used for faster execution unless they really need a higher custom version of Map,reduce and filter.Three: iOS get Modle,version,app
    • NSLog (@ "uniqueidentifier:%@", [[Uidevice Currentdevice] uniqueidentifier]);
    • NSLog (@ "Name:%@", [[Uidevice Currentdevice] name]);
    • NSLog (@ "SystemName:%@", [[Uidevice Currentdevice] systemName]);
    • NSLog (@ "systemversion:%@", [[Uidevice Currentdevice] systemversion]);
    • NSLog (@ "model:%@", [[Uidevice Currentdevice] model]);
    • NSLog (@ "Localizedmodel:%@", [[Uidevice Currentdevice] localizedmodel]);

    • App info (dictionary)
Nsdictionary *infodictionary = [[NSBundle Mainbundle] infodictionary]; Cfshow (infodictionary);

    • App Name
NSString *app_name = [infodictionary objectforkey:@ "cfbundledisplayname"];

    • App version
NSString *app_version = [infodictionary objectforkey:@ "cfbundleshortversionstring"];
    • App build version
NSString *app_build = [infodictionary objectforkey:@ "cfbundleversion"];
four; UIL and Uri

1. Abbreviations:

    • URI (Uniform Resource Identifier) uniform Resource identifier;
    • URL (Uniform Resource location) Uniform Resource Locator (or Uniform Resource Locator);
    • URN (Uniform Resource Name) uniform Resource naming.

Comparison of 2.URI and URLs

    • A. URIs are a relatively broad concept, URLs are a kind of URI, a subset of the URI naming mechanism, it can be said that URIs are abstract, and specifically to use URLs to locate resources.
    • B. every resource on the web, such as pictures, documents, videos, etc., is located by Uri, where the so-called positioning refers to the specific path on the server that the resources on the web are stored on the servers relative to the host server.
    • c. a URL is a string on the Internet that describes an information resource file, used on client programs and servers to locate the information needed by the client to connect to the server, not only locating the information resource, but also defining how to find the resource.
3. My vernacular understandingURI is a resource positioning mechanism, it is relatively general positioning of resources, not limited to the client and server, and the URL to locate all the resources on the Internet, as long as the resources on the Internet, there is a unique URL.

iOS development--Kinky skills Summary of various sexual techniques in the development of &ios (ii)

Related Article

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.