操人视频99青青av|亚洲a极淫交3P毛片电影|精品蜜桃人妻天天久|国产精品色婷婷免费|正规av网站在线免费观看|国产精品高清在线观看|免费成人网站在线|97干色五月天最黄三级无码片|在线免费观看黄色毛片A片|日韩无码视频一二三四区

ObjectC,NSURL,統(tǒng)一資源定位器 -電腦資料

電腦資料 時間:2019-01-01 我要投稿
【www.emoneyp.cn - 電腦資料】

    今天晚上最后一個例子,寫完休息娛樂一會,

ObjectC,NSURL,統(tǒng)一資源定位器

。

    URL,統(tǒng)一資源定位器,可以定位網(wǎng)絡(luò)上的一個資源。

    沒啥難的,還是對象、方法、API。和Java等語言沒有啥區(qū)別。

    不親自一點(diǎn)點(diǎn)寫一遍,印象不深,今后進(jìn)一步深入學(xué)習(xí)iOS時,會遇到很多問題,倒是再回頭看,也沒效率。

    代碼

////  main.m//  NSURLTest////  Created by fansunion on 15/12/2.//  Copyright (c) 2015年 demo. All rights reserved.//#import<foundation foundation.h="">int main(int argc, const char * argv[]) {    @autoreleasepool {      NSString* str = @"http://blog.csdn.net/FansUnion";        NSURL* url = [NSURL URLWithString:str];        NSString* scheme =[url scheme];        NSString* host = [url host];        NSString* port = [url port];        NSString* path =[url path];        NSLog(@"scheme : %@",scheme);        NSLog(@"host : %@",host);        NSLog(@"port : %@",port);        NSLog(@"path : %@",path);        //使用URL對應(yīng)的資源來初始化NSString對象        NSString* content =[NSString stringWithContentsOfURL: url encoding:NSUTF8StringEncoding error:nil];        NSLog(@"%@",content);    }    return 0;}</foundation>

    程序輸出

    2015-12-02 21:07:54.545 NSURLTest[5619:393442] scheme : http

    2015-12-02 21:07:54.546 NSURLTest[5619:393442] host : blog.csdn.net

    2015-12-02 21:07:54.546 NSURLTest[5619:393442] port : (null)

    2015-12-02 21:07:54.546 NSURLTest[5619:393442] path : /FansUnion

    2015-12-02 21:08:08.555 NSURLTest[5619:393442]

    更多html內(nèi)容,沒有展示出來,太長了,

電腦資料

ObjectC,NSURL,統(tǒng)一資源定位器》(http://www.emoneyp.cn)。

    比較奇怪的是,端口號port為啥是null,難道不是80么?

最新文章