iOS Development-Development Summary (IV)

Source: Internet
Author: User

One: Send and awk explanations
    • Sed-n P filenamesed----------------------------is a stream editor
    • awk ' BEGIN {print ' Hellow '} ' awk--------is a programming language tool for working with text.
Two: Summary of the method of transmitting value
    • Kvo the bottom layer will dynamically Phoenix new class, only a strong attribute (the property of an object can back multiple redemption listening, an object can listen to the other properties of multiple objects)
      • KVC/KVO is based on runtime
    • Agent, specification, code: one-on-one
    • notification, send and receive: one-to-many (a notification can be accepted by multiple objects, an object can accept multiple notifications)
Three: Block simple summary bloack is based on pointers and function pointers, pointers to the structure of the body! The value can be changed after using __block outside, because the block has sent the address in

By default in the stack, a copy operation to the block can put it into the heap and use it consistently, and another way is block_copy (blockname) non-arc inside

IV: Swift code update: Go to 2.0 Xcode 7 to convert the code into a swift 2 tool. The tool is located under the Edit menu of Xcode--convert > to Latest Swift Syntax.

V: decode string using GTMBASE64 encoding

    • GTMDefines.h GTMBase64.h GTMBASE64.M
You can find these three files here (GTMDefines.h on the second page, click on the Next button in the upper right corner to jump to the second page)

Six: Codec function (can encode and decode strings, pictures, Video: filepath replaced by the corresponding):

Read the file from the emulator and the document path of the real machine, write the file after encoding, and decode it.

Cryptographic functions

1-(void) Func_encodefile 2  3 {4  5     //nsstring *path = [Nshomedirectory () stringbyappendingformat:@ "/ Documents/test.png "]; 6  7     nsstring *filepath = [Nshomedirectory () stringbyappendingformat:@ "/documents/iphone4.mov"]; 8  9     Convert//file path to NSData12     nsdata *imagedataorigin = [NSData datawithcontentsoffile:filepath];14     1000//     unsigned char * cbyte = (unsigned char*) [Imagedataorigin bytes];20 + for     (int index = 0; (Index < [imagedataorigin length]) && (Index < 1000); index++, cbyte++)          (*cbyte = *cbyte) ^ arrayforencode[index];26     }28     // Base64 code for NSData     nsdata *imagedataencode = [GTMBase64 encodedata:imagedataorigin];32     [ Imagedataencode Writetofile:filepath atomically:yes];34 35}

Decryption function

1-(void) Func_decodefile 2  3 {4  5     //nsstring *filepath = [Nshomedirectory () stringbyappendingformat:@ "/ Documents/test.png "]; 6  7     nsstring *filepath = [Nshomedirectory () stringbyappendingformat:@ "/documents/iphone4.mov"]; 8  9     //read data corresponding to the encrypted file     nsdata *dataencoded = [NSData datawithcontentsoffile:filepath];14     16 17< c10/>//NSData base64 decoding of     nsdata *datadecode = [GTMBase64 decodedata:dataencoded];20     XOR the first 1000 bits     unsigned char * cbyte = (unsigned char*) [Datadecode bytes];26 for     (int index = 0; (Index < [datadecode length]) && (Index < 10); index++, cbyte++)     {         *cbyte = (*cbyte) ^ arrayforencode[index];32}34     [ Datadecode Writetofile:filepath atomically:yes];38}39  
Seven: Get each frame push-button:
1 [mimagegenerator generatecgimagesasynchronouslyfortimes:[nsarray arraywithobject:[nsvalue valueWithCMTime: Cmtimemakewithseconds (Time, Nsec_per_sec)] Completionhandler:   2     ^ (cmtime requestedtime, cgimageref image, Cmtime actualtime, avassetimagegeneratorresult result, Nserror *error)   3     {   4            NSLog (@ "Actual got image At Time:%f ", Cmtimegetseconds (Actualtime));          if (image)   5         {   6             [catransaction begin];   7             [Catransaction Setdisableactions:yes];   8             [layer setcontents: (ID) image];   9             //uiimage *img = [UIImage imagewithcgimage:image];  One             //uiimagewritetosavedphotosalbum (img, self, nil, nil);             [Catransaction commit];  +         }     ];  
Eight: iOS development stream Media common sense real-time streaming media transmission must ensure that the transmission speed of the packet is greater than the speed of the file, otherwise the user will see a video pause. Video quality degrades when the network is plugged, so it's better to ensure that the quality of the video is progressively downloaded.

Real-time Streaming media protocol:

    • RTSP (Real time streaming Protocol)
    • MMS (Microsoft Media Server Protocol)
    • HLS (Http Live streaming)

Here is the main introduction of HLS,

HLS (HTTP Live streaming) is an HTTP-based streaming solution developed by Apple for mobile devices such as the iphone, IPod, itouch and ipad Nine: m3u8 file conceptThe m3u8 file refers to the m3u file in the UTF-8 encoded format.  The m3u file is an indexed plain text file that is opened when the playback software does not play it, but instead finds the corresponding audio and video file's network address for online playback based on its index. Ten: Swift in Autoclosure @autoclosure automatically package an expression into a closure (closure)

iOS Development-Development Summary (IV)

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.