iOS開發-開發總結(四)

來源:互聯網
上載者:User

標籤:

一:send和awk解釋 
  • sed -n p filenamesed ----------------------------是一個流編輯器(stream editor)
  • awk ‘BEGIN {print “Hellow"}‘awk --------是一種用於處理文本的程式設計語言工具。
 二:傳值方式總結
  • KVO底層會動態長生新的類,只能堅挺屬性(一個對象的屬效能背多個兌現監聽,一個對象能監聽多個對象的其他屬性)
    • kvc/kvo底層是基於runtime
  • 代理,規範,代碼多:一對一
  • 通知,發送和接收:一對多(一個通知能被多個對象接受,一個對象能接受多個通知)
  三:block簡單小結 bloack時基於指標和函數指標的,指向結構體的指標!外面使用__block之后里面能修改值,是因為block將地址傳進去了

預設在棧裡面,對block做一次copy操作就能將它放到堆裡面並且一致使用它,還有一種方法是Block_copy(blockname)非Arc裡面

 

 四:swift代碼更新:轉2.0 Xcode 7中將代碼轉換成Swift 2的工具。該工具位於在Xcode的Edit菜單下--Convert > To Latest Swift Syntax。   

五:使用GTMBase64編碼解碼字串

  • GTMDefines.h GTMBase64.h GTMBase64.m
你可以在這裡找到這三個檔案(GTMDefines.h在第二頁,點擊右上方的next按鈕即可跳轉到第二頁) 

六:編解碼函數(可以編解碼字串、圖片、視頻:filePath換成相應的即可):

從模擬器和真機的Documents路徑下讀取檔案,編碼後寫入檔案;讀出來解碼

// 加密函數

 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     10 11     //檔案路徑轉換為NSData12 13     NSData *imageDataOrigin = [NSData dataWithContentsOfFile:filePath];14 15     16 17     // 對前1000位進行異或處理18 19     unsigned char * cByte = (unsigned char*)[imageDataOrigin bytes];20 21     for (int index = 0; (index < [imageDataOrigin length]) && (index < 1000); index++, cByte++)22 23     {24 25          *cByte = (*cByte) ^ arrayForEncode[index];26 27     }28 29     //對NSData進行base64編碼30 31     NSData *imageDataEncode = [GTMBase64 encodeData:imageDataOrigin];32 33     [imageDataEncode writeToFile:filePath atomically:YES];34 35 }

 

// 解密函數

 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     10 11     // 讀取被加密檔案對應的資料12 13     NSData *dataEncoded = [NSData dataWithContentsOfFile:filePath];14 15     16 17     // 對NSData進行base64解碼 18 19     NSData *dataDecode = [GTMBase64 decodeData:dataEncoded];20 21     22 23     // 對前1000位進行異或處理24 25     unsigned char * cByte = (unsigned char*)[dataDecode bytes];26 27     for (int index = 0; (index < [dataDecode length]) && (index < 10); index++, cByte++)28 29     {30 31         *cByte = (*cByte) ^ arrayForEncode[index];32 33     }34 35     36 37     [dataDecode writeToFile:filePath atomically:YES];38 }39  
 七:擷取每一幀推按:
 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    10             //UIImage *img = [UIImage imageWithCGImage:image];  11             //UIImageWriteToSavedPhotosAlbum(img, self, nil, nil);  12    13             [CATransaction commit];  14         }  15     }];  
 八:iOS開發之流媒體常識 即時資料流媒體傳輸必須保證資料包的傳輸速度大於檔案的播放速度,否則使用者看到的視頻會出現暫停。當網路堵塞情況下視頻品質會下降,所以要想保證視頻的品質漸進式下載會更好一些。

即時資料流媒體協議:

  • RTSP(Real Time Streaming Protocol)
  • MMS(Microsoft Media Server protocol)
  • HLS(Http Live Streaming)

這裡主要介紹HLS,

 HLS(HTTP Live Streaming)是蘋果公司針對iPhone、iPod、iTouch和iPad等行動裝置而開發的基於HTTP協議的流媒體解決方案  九:M3U8檔案概念M3U8檔案是指UTF-8編碼格式的M3U檔案。M3U檔案是記錄了一個索引純文字檔案,開啟它時播放軟體並不是播放它,而是根據它的索引找到對應的音視頻檔案的網路地址進行線上播放。  十:swift中autoclosure @autoclosure 把一句運算式自動封裝成一個閉包(closure)  

iOS開發-開發總結(四)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.