成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

WIFI傳輸

移動開發(fā)
類似多看和iReader的WIFI傳輸功能。

源碼簡介:類似多看和iReader的WIFI傳輸功能。

源碼效果:

源碼片段:

  1. #import "CocoaWebResourceViewController.h" 
  2.   
  3. @implementation CocoaWebResourceViewController 
  4.   
  5. // load file list 
  6. - (void)loadFileList 
  7.     [fileList removeAllObjects]; 
  8.     NSString* docDir = [NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]; 
  9.     NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] 
  10.                                       enumeratorAtPath:docDir]; 
  11.     NSString *pname; 
  12.     while (pname = [direnum nextObject]) 
  13.     { 
  14.   
  15.         [fileList addObject:pname]; 
  16.     } 
  17.   
  18. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
  19. - (void)viewDidLoad { 
  20.     fileList = [[NSMutableArray alloc] init]; 
  21.     [self loadFileList]; 
  22.       
  23.     // set up the http server 
  24.     httpServer = [[HTTPServer alloc] init]; 
  25.     [httpServer setType:@"_http._tcp."];     
  26.     [httpServer setPort:8080]; 
  27.     [httpServer setName:@"CocoaWebResource"]; 
  28.     [httpServer setupBuiltInDocroot]; 
  29.     httpServer.fileResourceDelegate = self; 
  30.   
  31.     [super viewDidLoad]; 
  32.   
  33.   
  34. - (void)didReceiveMemoryWarning { 
  35.     [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 
  36.     // Release anything that's not essential, such as cached data 
  37.   
  38.   
  39. - (void)dealloc { 
  40.     httpServer.fileResourceDelegate = nil; 
  41.     [httpServer release]; 
  42.     [fileList release]; 
  43.     [super dealloc]; 
  44.   
  45. #pragma mark actions 
  46. - (IBAction)toggleService:(id)sender 
  47.     NSError *error; 
  48.     if ([(UISwitch*)sender isOn]) 
  49.     { 
  50.         BOOL serverIsRunning = [httpServer start:&error]; 
  51.         if(!serverIsRunning) 
  52.         { 
  53.             NSLog(@"Error starting HTTP Server: %@", error); 
  54.         }        
  55.         [urlLabel setText:[NSString stringWithFormat:@"http://%@:%d", [httpServer hostName], [httpServer port]]]; 
  56.     } 
  57.     else 
  58.     { 
  59.         [httpServer stop]; 
  60.         [urlLabel setText:@""]; 
  61.     } 
  62.   
  63. #pragma mark WebFileResourceDelegate 瀏覽器上傳文件后的回調(diào)方法 
  64. // number of the files 
  65. - (NSInteger)numberOfFiles 
  66.     return [fileList count]; 
  67.   
  68. // the file name by the index 
  69. - (NSString*)fileNameAtIndex:(NSInteger)index 
  70.   
  71.     return [fileList objectAtIndex:index]; 
  72.   
  73. // provide full file path by given file name 
  74. - (NSString*)filePathForFileName:(NSString*)filename 
  75.     NSString* docDir = [NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]; 
  76.   
  77.     return [NSString stringWithFormat:@"%@/%@", docDir, filename]; 
  78.   
  79. // handle newly uploaded file. After uploading, the file is stored in 
  80. // the temparory directory, you need to implement this method to move 
  81. // it to proper location and update the file list. 
  82. - (void)newFileDidUpload:(NSString*)name inTempPath:(NSString*)tmpPath 
  83.     if (name == nil || tmpPath == nil) 
  84.         return
  85.     NSString* docDir = [NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]; 
  86.     NSString *path = [NSString stringWithFormat:@"%@/%@", docDir, name]; 
  87.     NSFileManager *fm = [NSFileManager defaultManager]; 
  88.     NSError *error; 
  89.   
  90.     if (![fm moveItemAtPath:tmpPath toPath:path error:&error]) 
  91.     { 
  92.         NSLog(@"can not move %@ to %@ because: %@", tmpPath, path, error ); 
  93.     } 
  94.           
  95.     [self loadFileList]; 
  96.       
  97.   
  98. // implement this method to delete requested file and update the file list 
  99. - (void)fileShouldDelete:(NSString*)fileName 
  100.   
  101.     NSString *path = [self filePathForFileName:fileName]; 
  102.     NSFileManager *fm = [NSFileManager defaultManager]; 
  103.     NSError *error; 
  104.     if(![fm removeItemAtPath:path error:&error]) 
  105.     { 
  106.         NSLog(@"%@ can not be removed because:%@", path, error); 
  107.     } 
  108.     [self loadFileList]; 
  109.   
  110. @end 

下載地址:http://down.51cto.com/data/2103329

責(zé)任編輯:倪明 來源: devstore
相關(guān)推薦

2010-03-24 15:31:34

2016-02-22 09:34:24

WiFi光纖傳輸速度

2015-11-19 14:46:40

2012-06-28 20:34:59

極速WiFi渦流電波WiFi

2011-08-01 13:05:27

路由器WiFi無線

2012-06-14 10:56:14

WiFi7Gbps無線

2013-06-24 10:40:01

千兆WiFi802.11ac無線網(wǎng)絡(luò)

2021-10-08 14:43:24

WiFi 5WiFi 6遠(yuǎn)程

2021-06-23 09:03:19

iPhone WiFi bug漏洞

2015-06-11 13:07:31

WIFIWIFI安全風(fēng)險示意圖

2022-08-11 15:44:30

WiFi 6WiFi 7物聯(lián)網(wǎng)

2010-03-11 13:12:14

Wi-Fi無線網(wǎng)絡(luò)傳輸

2009-02-18 09:42:58

TCPISO傳輸

2017-02-07 16:20:39

光纖無線通信

2012-06-25 09:38:33

全球最快手機(jī)快牙

2015-08-13 17:29:35

WiFi

2019-09-20 09:22:00

藍(lán)牙WiFiZigBee

2020-02-26 08:23:30

WiFi 6WiFi 5網(wǎng)絡(luò)

2018-11-26 06:22:32

WiFi無線網(wǎng)絡(luò)路由器

2021-10-28 11:48:17

WiFi網(wǎng)絡(luò)網(wǎng)絡(luò)安全WiFi嗅探
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 狠狠操电影 | 日韩av一二三区 | 老头搡老女人毛片视频在线看 | 精品国产鲁一鲁一区二区张丽 | 成人免费在线观看视频 | 午夜一区二区三区在线观看 | 国产综合精品 | 婷婷丁香在线视频 | 亚洲成人免费视频在线观看 | 国产精品国产精品国产专区不卡 | 久久精品视频播放 | 日韩在线小视频 | 亚洲国产精品久久人人爱 | 成人在线观看网址 | 狠狠干美女| www狠狠爱com | 色婷婷国产精品 | 拍真实国产伦偷精品 | 亚洲精品一区二区冲田杏梨 | 日韩视频二区 | 久久亚洲综合 | 精品国产视频在线观看 | 日韩三级电影在线看 | 欧洲亚洲精品久久久久 | 国产农村妇女精品一区 | 欧美精品综合在线 | 99久久久久久99国产精品免 | 日韩成人在线免费观看 | 伊人一区 | 罗宾被扒开腿做同人网站 | 超碰人人在线 | 精品在线一区二区三区 | 国产精品精品视频一区二区三区 | 欧美亚洲国产日韩 | 天堂综合 | 国产精品久久久久久av公交车 | 久久精品国产99国产 | 亚洲热在线视频 | 在线日韩精品视频 | 国产日韩欧美一区二区 | 秋霞av国产精品一区 |