본문 바로가기

프로그래밍/iOS

NSURL의 속성

  1. NSURL의 속성
    - URL: http://www.testUrl.com/notice/contents?a=1&b=2&c=3 (설명을 위한 임시 URL)
    - scheme: http (:// 이전의 텍스트)
    - host: www.testUrl.com (://과 맨 처음 / 사이의 텍스트)
    - path: /notice/contents (맨 처음 /와 ? 사이의 텍스트)
    - query: a=1&b=2&c=3 (? 이후의 텍스트)


  2. 예제 코드
  3. NSString *strUrl = @"http://www.testUrl.com/notice/contents?a=1&b=2&c=3"; NSURL *requestURL = [NSURL URLWithString:strUrl]; ///////////////////////////////////////////////////////////////////////////////// // scheme host path query // // ex) "http://www.testUrl.com/notice/contents?a=1&b=2&c=3" // ///////////////////////////////////////////////////////////////////////////////// NSLog(@"request URL : %@", requestURL); NSLog(@"request URL scheme : %@", [requestURL scheme]); NSLog(@"request URL host : %@", [requestURL host]); NSLog(@"request URL path : %@", [requestURL path]); NSLog(@"request URL query : %@", [requestURL query]);



  4. 활용 용도
    - 서버와 속성별로 규칙을 정하여 앱 내부 URL로 활용 가능(scheme을 앱 이름으로 하여)
    - 속성을 지지고 볶으면 여러 용도로 사용 가능할 듯!



'프로그래밍 > iOS' 카테고리의 다른 글

NSAutoreleasePool VS @autorelease block  (0) 2017.04.10
iOS 식별자(identifier)  (2) 2017.04.07
nil, Nil, null, NSNull의 차이  (0) 2017.04.06
new VS alloc init  (2) 2017.04.05
frame VS bounds  (5) 2017.04.04