junecnol
junecnol
Jacob YO !!!
189 posts
Don't wanna be here? Send us removal request.
junecnol · 6 years ago
Text
youtube
2 notes · View notes
junecnol · 6 years ago
Text
Deep learning course 4 week 4 - andrew ng
https://www.youtube.com/watch?v=-FfMVnwXrZ0&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=32
C4W4L01 What is face recognition
https://www.youtube.com/watch?v=96b_weTZb2w&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=33
C4W4L02 One Shot Learning
얼굴인식 알고리즘의 경우 한 사람의 이미지가 하나만 있거나 적은수의 이미지를 가지고 있고 부족한 데이터를 가지고 문제를 해결해야 한다. 
Tumblr media Tumblr media
알고리즘 d 는 두 이미지 얼굴간의 차이점을 찾아내는 알고리즘이다. 결과값이 일정보다 크면 다른 사람으로 보고 일정값보다 작으면 같은 사람으로 본다. 
2 notes · View notes
junecnol · 6 years ago
Text
Deep learning course 4 week 3 - andrew ng
https://www.youtube.com/watch?v=GSwYGkTfOKk&index=23&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF
C4W3L01 Object Localization
Tumblr media
위 그림의 왼쪽부터 오르쪽으로 단계별 진화되는 모습이다.
Tumblr media Tumblr media
최종 결과값은 y 이다. pc는 이미지안에 1 -4 번에 해당하는 object가 있는지 없느지 유무를 나타낸다. bx - bw는 박스의 위치 크기를 나타낸다. c1 - c3는 object 유무를 나타낸다. pc 값이 0인경우 즉 object가 없는 경우 나머지 값들은 그냥 무시한다. 
loss를 구하는 경우에 각각의 항목에 대해 squared error를 이용한다. 다만 pc가 0 인 경우 다른 항목에 대해서는 loss를 구하지 않는다. 
https://www.youtube.com/watch?v=rRB9iymNy1w&index=24&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF
C4W3L02 Landmark Detection
Tumblr media
전 시간 강의와 비슷하다. 다만 좀더 많은 landmarks를 출력한다. 
https://www.youtube.com/watch?v=XdsmlBGOK-k&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=25
C4W3L04 Convolutional Implementation Sliding Windows
Tumblr media
fully connected layer를 convolution layer로 표현가능하다.
Tumblr media
위 그림의 중간을 보면 파란색이 윈도우이며 노란색이 검색 대상 이미지 이다. 파란색의 윈도우가 움직일수 있는 방법은 좌우상하로 4가지 이며 이것은 맨 마지막 결과에서의 matrix와 일치하게 된다. 
Tumblr media
https://www.youtube.com/watch?v=5e5pjeojznk&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=26
C4W3L03 Object Detection
Tumblr media
sliding window의 문제는 자원이 많이 필요하다는 점이다. stride값을 조정으로 자원소비를 줄일수있다.
https://www.youtube.com/watch?v=ANIzQ5G-XPE&index=27&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF
C4W3L06 Intersection Over Union
Tumblr media
0.5 값은 보통 사용하는 값이며 특정한 이유는 없다. 0.6, 0.7을 쓰기도 하지만 낮은 값은 잘 쓰지 않는다.
https://www.youtube.com/watch?v=VAo84c1hQX8&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=29
C4W3L07 Nonmax Suppression
Tumblr media
같은 object이 여러번 탐색될수 있다. 이런경우에 대한 처리 방법은 아래 그림을 참조한다.
Tumblr media
우선 pc ( object일 가능성 )이 0.6 이하인 것은 없앤다. 가장 높은 pc값을 가진 박스를 선택한다. 가장 높은 pc값을 가진 box와 겹치며 iou 값이 0.5이상인 박스는 삭제한다. 
https://www.youtube.com/watch?v=RTlwl2bv0Tg&index=28&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF
C4W3L08 Anchor Boxes
한 위치에 여러 object가 있고 이들을 다 표시하기 위한 방법으로 anchor box방법이 있다.
Tumblr media Tumblr media
anchor box의 경우 object가 있는 위치를 확인한 grid cell과 anchor box의 iou를 확인하고 수치가 높은 것을 이용한다. 여러개 있는 경우 여러개 표시한다. 기존에 하나의 object만을 확인할수 있는 경우 3 * 3 * 8 크기의 matrix이지만 여러개를 표시할수 있게 하는 경우  8 * 갯수 만큼으로 늘려 주어야 한다.  
Tumblr media
https://www.youtube.com/watch?v=9s_FpMpdYW8&index=30&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF
C4W3L09 YOLO Algorithm
Tumblr media Tumblr media Tumblr media
https://www.youtube.com/watch?v=6ykvU9WuIws&list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF&index=31
C4W3L10 Region Proposals
Tumblr media
모든 부분에 대해서 탐색을 하기 보다 특이한 부분이 있는 부분만 검색하는 방법이다. 특이한 부분을 찾아내는데에는 segmentation algorithm 을 사용한다.
Tumblr media
기본적으로 r cnn 만으로는 속도가 느려서 convolutional network의 기능 같이 사용해서 개선한 방법( faster r cnn )을 사용하기도 한다. 그래도 yolo보다는 속도가 느리다.
2 notes · View notes
junecnol · 6 years ago
Text
Machine Learning by Andrew Ng week 3 ( Summary )
0 notes
junecnol · 7 years ago
Text
android animation
ObjectAnimator ( property animator라고도 불린다 )를 이용한 방법
     때때로 시작점과 종료점을 구하는데 도움을 주는 TypeEvaluator를 덧붙여 사용하기도 한다.
     AnimatorSet을 통해 여러개의 animator을 연결, 동시 진행 가능하다.
transformation property 값의 변경을 이용한 방법
     getRotation , setRotation
     getPivotX, setPivotX, getPivotY, setPivotY
     getScaleX, setScaleX, getScaleY, setScaleY
     getTranslationX, setTranslationX, getTranslationY, setTranslationY 
android 5.0 lollipop부터 등장한 새로운 animation 구현방법  - material design에 관련된 것들
state list animators, animated state list drawables, circular reveals, shared element transitions 
1 note · View note
junecnol · 7 years ago
Text
package manager, dependency manager
Homebrew 
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system. 
https://brew.sh/
nvm and npm
nvm (Node Version Manager) is a tool that allows you to download and install Node.js. Check if you have it installed via nvm --version.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
npm (Node Package Manager) is a tool that allows you to install javascript packages. Check if you have it installed via npm --version.
npm comes with Node.js so if you have node installed (node --version) you most likely have npm installed as well.
You don't need nvm unless you you want to keep multiple versions of Node.js installed on your system or if you'd like to upgrade your current version.
CocoaPods 
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
https://cocoapods.org/
1 note · View note
junecnol · 7 years ago
Link
original source :  https://stackoverflow.com/questions/24814646/attach-parameter-to-button-addtarget-action-in-swift
You cannot pass custom parameters in addTarget:.One alternative is set the tag property of button and do work based on the tag.
button.tag = 5 button.addTarget(self, action: "buttonClicked:",    forControlEvents: UIControlEvents.TouchUpInside)
Or for Swift 2.2 and greater:
button.tag = 5 button.addTarget(self,action:#selector(buttonClicked),    forControlEvents:.TouchUpInside)
Now do logic based on tag property
@objc func buttonClicked(sender:UIButton) {    if(sender.tag == 5){        var abc = "argOne" //Do something for tag 5    }    print("hello") }
1 note · View note
junecnol · 7 years ago
Link
original source : https://stackoverflow.com/questions/25471114/how-to-validate-an-e-mail-address-in-swift
I would use NSPredicate:
func isValidEmail(testStr:String) -> Bool {            let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"    let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)    return emailTest.evaluate(with: testStr) }
for versions of Swift earlier than 3.0:
func isValidEmail(testStr:String) -> Bool {    // print("validate calendar: \(testStr)")    let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"    let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)    return emailTest.evaluate(with: testStr) }
for versions of Swift earlier than 1.2:
class func isValidEmail(testStr:String) -> Bool {    println("validate calendar: \(testStr)")    let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"    if let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx) {        return emailTest.evaluateWithObject(testStr)    }    return false }
1 note · View note
junecnol · 7 years ago
Link
original source : https://stackoverflow.com/questions/47581777/how-do-you-create-textfield-padding-in-swift-4
#1 answer
https://stackoverflow.com/a/47583605
Customized way to add padding in "left", "right" or "both" side od UITextField.
Step 1:- Add this UITextfield extension
extension UITextField {    enum PaddingSide {        case left(CGFloat)        case right(CGFloat)        case both(CGFloat)    }    func addPadding(_ padding: PaddingSide) {        self.leftViewMode = .always        self.layer.masksToBounds = true        switch padding {        case .left(let spacing):            let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: spacing, height: self.frame.height))            self.leftView = paddingView            self.rightViewMode = .always        case .right(let spacing):            let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: spacing, height: self.frame.height))            self.rightView = paddingView            self.rightViewMode = .always        case .both(let spacing):            let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: spacing, height: self.frame.height))            // left            self.leftView = paddingView            self.leftViewMode = .always            // right            self.rightView = paddingView            self.rightViewMode = .always        }    }         }
Step 2: How to use
// 1.  To add left padding yourTextFieldName.addPadding(.left(20)) // 2.  To add right padding yourTextFieldName.addPadding(.right(20)) // 3. To add left & right padding both yourTextFieldName.addPadding(.both(20))
1 note · View note
junecnol · 7 years ago
Video
youtube
firebase cloud function basic “hello world”
my review point is 9 
firebase init
firebase deploy
getting a function endpoint link
다음 비디오 :  https://youtu.be/nezhsGvrhaI
여기에서는 console log에 출력, 확인하는 방법, query string을 request에 포함하는 방법
1 note · View note
junecnol · 7 years ago
Link
제 목 : 멀홀랜드 드라이브(2001)
번호 : 22652
글쓴이 : 최서희 (ubelieve) - CINESeOUL
조회수 : 3155
추천수 : 37
등록일 : 2001-11-23
결론부터 말하자. 이영화의 전반부는 꿈이며 후반부는 현실이다.
고로 다이앤/카밀라가 실제 인물이고 베티/리타는 환상속의 인물인 것이다.
이 영화는 철저하게 다이앤의 시선에서 이루어진다.
다이앤은 캐나다에서 스타덤의 꿈을 안고 할리우드라 날라 온 지방 지르박 콘테스트 우승자. 그는 돈도 없고 빽도 없이 청운의 꿈을 안고 왔을 뿐이다. 갖가지 영화 단역 오디션을 응시하면서 카밀라라는 여자를 만나게 된다.
카밀라는 원하는 것을 얻기 위해 무슨 짓이라도 할 수 있는 여자. 그 역시 스타가 되려는 목표를 갖고 있다. 카밀라는 자신이 더 돋보이기 위해, 혹은 이용하기 위해 다이앤에게 접근하며 다이앤과 연인관계로 발전하고 감독을 유혹해 주역의 자리까지 올라선다. 카밀라는 여러 명에게 사랑을 받는 상태를 즐기는 인물로 감독과의 결혼 발표 장소에 다이앤을 불러 지켜 보게하고 또 그런 자리에서도 또 다른 여자 연인에게 대담한 키스를 하기도 한다.
질투에 불타는 다이앤은 청부살인을 의뢰하고 청부살인자는 여자가 확실히 죽었다는 의미로 파란열쇠를 보낸다고 한다.
살인을 의뢰한 후 다이앤은 후회, 좌절, 죄책감에 시달린다. 약 3주간 마약이나 환각제의 영향으로 환상 혹은 꿈속에서 집안에 칩거한다.
그의 상상 속에서 일어난 일이 영화의 2/3을 차지하는 전반부이다. 꿈속(혹은 환상속)에서 그는 현실의 자기 모습과 매우 다르다. 현실속의 그녀는 스타가 되지 못한 좌절감으로 항상 어둡고 우울하며 여성스럽지도 못하고 매력적이지 않다. 하지만 꿈속에서 그녀는 베티라는 인물로 자신을 대체시킨다. 밝고 명랑하며 동정심이 많고 항상 업된 붕붕 뜬 기분으로 살아가는 베티. 그녀 역시 캐나다 촌구석에서 온 스타지망생이지만 할리우드에서 활동하고 있는 배우인 이모가 있다.
다이앤이 만들어낸 또다른 자신인 베티는 모든 면에서 자신과 정반대이다. 관객들은 카밀라와 리타가 동일인물이라는 것은 한눈에 알아차렸으나 다이앤과 베티가 동일인물이라는 것을 끝까지 깨닫지 못하고 지나간 둔감한 관객도 있었다. 그 이유는 표정부터 옷차림까지 다이앤과 베티가 철저히 달랐기 때문이다. 다이앤은 매니쉬한 정장바지에 흰색셔츠를 입고 동성애관계에 있어서도 관계를 주도하는 남성적인 타입 이었으나 베티는 핑크색+반짝이 달린 귀염성 있는 패션에 헤어스타일도 지극히 여성스러웠기 때문이다. 게다가 얼굴 표정 또한 완전히 달랐고 말투, 행동등도 판이했다. 또 베티는 리타의 유혹에 넘어가 연인이 된다. 자신이 일방적으로 카밀라를 좋아하는 현실이 못마땅한 다이앤은 베티로 자신의 욕망을 충족한다.
꿈속에서 카밀라, 즉 기억상실자 리타는 세상에 내버려진 아이와도 같다. 멀홀랜드 드라이브에서 살해당할 뻔 하다가 구사일생으로 도망쳐 기억도 없고 가진 것은 출처모르는 돈뭉치 뿐. 꿈속에서 리타는 베티에게 전적으로 의지하며 살아간다. 카밀라의 성격이 대담하고 당당했던데 비해 리타는 소심하고 겁이 많은 성격이다. 베티는 리타의 기억을 찾아주기 위해 성심성의껏 모든 일을 다하고 리타가 베티를 따라가기만 할뿐이다.
이건 다이앤의 꿈속이다. 다이앤은 '내가 가질 수 없는 것은 부숴버린다'는 생각으로 카밀라를 죽였다. 하지만 그의 진심은 카밀라가 자신을 사랑해주기만을 바랬다. 그래서 다이앤은 꿈속에서 카밀라가 죽음에서 빠져나와서 자신과 함께있다고 상상한 것이다. 또 현실속의 카밀라가 자신을 제멋대로 휘두르고 애정을 볼모로 자신을 고문(감독과의 키스장면을 지켜보게 한점, 결혼발표때 다이앤을 불러 자기비하를 느끼게 한점)했던 것에 비해 환상속의 카밀라(리타)는 너무나도 연약해 베티의 도움이 없이는 금방이라도 깨질것같은 약하디 약한 존재이다.
그 꿈속에서는 다이앤이 청부살인을 의뢰한 킬러도 나온다. 꿈속의 킬러는 어리숙하다. 또다른 청부살인(검은 책을 찾는 장면)을 하면서도 목표인물을 죽이다 실수를 해 코믹한 상황을 연출하며 연거푸 또 다른 2명을 죽이고 방범 벨까지 울려 화재탈출계단을 통해 허겁지겁 도망가는 웃기는 킬러이다. 이 장면이 전체내용과 관계없어 보여 산만해보일 수 있지만 이 또한 다이앤의 속마음의 표현이다. 그는 내심 자신이 의뢰한 킬러가 용이주도치 못한 인물이어서 카밀라가 죽지 않길 바라기 때문이다.
이제 감독과 hollywood show biz에 대해 얘기해보자. 현실 속에서 감독은 배우자가 없는 상태이며 카밀라와의 결혼 발표를 한다. 하지만 꿈속에서 그는 기혼자이며 아내는 청소부와 남편이 보는 앞에서 바람을 피우고도 오히려 큰소리를 친다. 현실 속에서 영화세트장을 마음껏 호령(카밀라와의 키스 리허설을 하며 스텝들에게 불끄라고 호통침)하는 지배적 인물이지만 꿈속에서는 아내에게 끽소리 못하고 아내의 정부에게 얻어맞는 한심한 사람이다.
또 그는 새로운 영화 촬영을 위해 여배우 캐스팅 중에 마피아로 추측되는 검은 세력에게 위협을 받는다. 그들이 제시하는 여배우를 캐스팅 하지 않을 경우 그는 경제적으로 파산되며 영화 산업계에 완전히 매몰될 것이라는 협박을 받고 그는 마피아들이 말하는 "This is the girl"을 어쩔 수 없이 뽑는다. 이 부분에서는 힘의 논리에 따라 움직이는 'evil hollywood(사악한 할리우드)'의 면모가 잘 드러나있다. '윗분들'의 지시에 따르지 않으면 촬영이 취소되고 감독이 매장되는 사회. 지금껏 비주류를 고집해온 린치 감독의 할리우드 비판적 목소리가 담겨있는 것이다.
마피아가 고집한 '바로 그여자'의 이름 역시 '카밀라'. 그런데 꿈속의 카밀라는 현실 속에서 카밀라가 감독과의 결혼발표장소에서 대담하게 키스를 나누었던 금발 여인이다. 다이앤도 그 영화의 오디션에 응모하지만 어이된 연유로 오디션을 포기하고 리타에게 황급히 돌아간다. 현실 속에서 다이앤은 주연자리는 카밀라에게 빼앗기고 항상 단역만 할뿐이었다. 그동안 자신이 그런 대우를 받았던 이유를 꿈속에서 그는 이렇게 합리화한다. '지금까지 카밀라가 인정받았던 이유는 실력이 뛰어나서가 아니라 누군가 밀어주기 때문이야. 나도 그러한 빽이 있었다면 훨씬 더 잘나갈 수 있었을 텐데'라고 말이다.
그리고 감독의 어머니/베티이모네 집주인 '코코'에 대한 한마디. 결혼발표식에서 만난 감독의 어머니 코코는 지극히 냉정하고 차가운 사람이다. 지르박 콘테스트에서 우승하고 그 운빨을 믿으며 할리우드에 와서 지금껏 카밀라의 도움으로 단역에 근근히 출현하고 있다는 다이앤의 말에 코웃음을 치면서 마음껏 그를 무시해준다. 하지만 꿈속에서 그는 베티이모네 집주인/관리인으로 나오면서 어머니처럼 그를 보살펴주고 도와준다. 다이앤은 카밀라를 빼앗아간 감독을 질투하면서도 한편으로는 그에게 사랑받고 인정받고 싶어했다. 그래서 꿈속 오디션 장소에서 베티는 감독과 운명적으로 눈이 마주쳐 서로 넋을 잃고 쳐다보며 감독의 어머니에게도 사랑을 받고 싶은 욕망을 꿈속에서 충족한다.
영화의 보조적 인물 몇몇. 관객에게 앞으로 일어날 일을 알려주는 역할을 한다.
다이앤이 살인을 청부했던 식당에서 식사한 두 명의 남자. 그중 하나는 그 식당에서의 악몽을 얘기하고 그 꿈을 확인하기 위해 식당 밖 벽 뒤로 갔다가 검은 괴물을 보고 갑작스러운 죽음을 맡는다. 그는 식당에서 뭔가 무서운 일이 일어나는 꿈을 꾸었고 그 일을 모두 조종하는 것은 벽 뒤의 괴물이라고 했다. 그의 악몽은 자신의 죽음을 예고하는 것이기도 하지만 다이앤이 카밀라의 살인을 의뢰하는 끔찍한 일, 또 그로 인해 다이앤도 자살하는 것을 의미한다.
또 베티의 아파트에 사는 기괴한 할머니도 끔찍한 일이 일어나고 있다고 경고한다. 이는 현실속에서 카밀라가 죽었고 그로인해 다이앤 자신도 죽을 것이라는 것을 말해준다. 즉 꿈속에서도 다이앤은 자신의 자살을 직감하고 있었기에 자신의 꿈에 이런 인물을 등장시킨 것이다. 다이앤이 자신의 자살을 예견하고 있다는 사실은 베티가 리타를 다이앤의 아파트로 인도하는 장면에도 나타나있다. 들어가기기 무서워하는 리타를 이끌고 베티는 자신의 시체가 있는 방으로 리타를 데리고 들어간다. 시신이 부패해 있기에 얼굴을 알아보지 못하게 한 감독의 트릭이 모두를 속였을 뿐이다.
그리고 엔딩에 나오는 벽뒤의 검은 괴물. 그는 이 모든 애증과 욕망의 운행자인 조물주 혹은 창조주이다. 우리의 운명은 희망적이지 않고 이 모든 것이 악순환을 이룬다는 것은 마지막 순간에 그의 손에 들어있는 파란 상자가 상징한다.
마지막 해명. 실렌시오 극장에서 그들은 상자에 맞는 열쇠를 발견하며 그 열쇠를 꼽는 순간 현실로 돌아온다. 그럼 실렌시오 극장은 무엇일까? 그곳은 베티와 리타가 자신의 정체성과 운명을 깨닫는 곳이다. 눈에 보이는 것이 진실은 아니라는 신비스러운 콧수염 남자의 말은 우리 모두에게 던지는 감독의 메시지이다.
그런데 이건 눈치챘는가? 실렌시오 극장 이층석에 있는 파란 머리를 한 기괴한 귀부인의 정체를. 그건 바로 카밀라이다. 자막이 올라가기 직전 화면은 다시 실렌시오 극장으로 돌아가 파란머리 귀부인을 클로즈업한다. 이는 '여지'를 남겨둔다. 그 여인 때문에 우리는 '이게 정말 다이앤의 꿈속 맞아?'라고 의문을 품게 된다. 결국 감독은 전형적인 평면적 스토리텔링 구조에서 벗어나 관객의 참여를 유도해 보는 사람의 마음대로 줄거리를 결정할 자유를 주었다. 하지만 결국 확실히 옳은 것은 아무도 찾아낼 수 없다는 지독한 허무를 우리에게 안겨주기도 한다. 하지만 우리는 손을 놓고 방관한 채 '답은 없어. 찾아내는 것이 오히려 어리석은 짓이야'라며 달관�� 수만은 없다.
데이빗 린치. 결코 녹록치 않은 감독이다.
3 notes · View notes
junecnol · 7 years ago
Video
youtube
Swift: Create Facebook's Image Zooming Animation using Core Animation my review point is /10
0 notes
junecnol · 7 years ago
Video
youtube
my review point is 10/10
Generics and Array Extension 설명
2 notes · View notes
junecnol · 7 years ago
Link
original source : https://stackoverflow.com/questions/25471024/in-ios-apps-whats-the-difference-between-the-main-bundle-and-the-documents-di
the mainBundle is the installed app
it is the size of the extracted ipa (you can see that in xcode beforehand)
it is ReadOnly and won’t contain user files (e.g. documents)
deleted with your app (it is the app)
when updating from the App Store, older ioses replace the whole bundle, downloading it as a whole. newer oses 6+ IIRC, do delta updates, only downloading changed files. you can’t say how much is downloaded – at least the amount of bytes you changed.
the documents dir is where your user generated contents are stored.
Its size depends on what your user/your app creates as documents ;) it starts with 0 mb
It is ReadWrite
deleted with your app
remains untouched by updates
that answers question 1 and 3 and 4
question 2 is wrong .. a filesystem folder doesn’t consume memory unless files are loaded by the app/the os
the os obviously loads the necessary parts of your app and the required frameworks
your app can load documents.
memory usage is only vaguely / not really related to file size
2 notes · View notes
junecnol · 7 years ago
Link
original source : https://stackoverflow.com/questions/16176911/nsurl-path-vs-absolutestring
Question 1:
What is the actual difference between these methods?
Let's analyze this writing 6 lines of code - 3 for a local and 3 for http URL - and playing around with them a little bit.
Let's create an NSURL using the file:// scheme. If you ask yourself why there are 3 / after file: you should remember that a complete URL exists of a scheme (file:// and absolute or relative path (you can find more information on creating URLs in RFC 1808 on page 3). We use an absolute path which starts with a / so that we end up with ///.
NSURL *aLocalURL = [NSURL URLWithString:@"file:///Users/dennis/Desktop/"]; NSLog(@"absolute string: %@", aLocalURL.absoluteString); NSLog(@"path: %@", aLocalURL.path);
Output:
absolute string: file:///Users/dennis/Desktop/ path: /Users/dennis/Desktop
So we see that absoluteString still knows its scheme whereas path doesn't have this information anymore.
Note: path is a file (directory) URL and as the docs state, the trailing slash it is stripped.
Now let's take a look at remote URLs. With these type of URLs most people are more familiar. We create it using the same procedure as for local URLs. Our scheme is now http:// and our pathis www.apple.com/.
NSURL *anHTTPURL = [NSURL URLWithString:@"http://www.apple.com/"];   NSLog(@"absolute string: %@", anHTTPURL.absoluteString); NSLog(@"path: %@", anHTTPURL.path);
Output:
absolute string: http://www.apple.com/ path: /
Again, we see that the absolute string still knows its scheme but path is now /. So path seems to be not an appropriate way when working with remote URLs.
However, when we have an URL like http://www.apple.com/index.html we get
absolute string: http://www.apple.com/index.html path: /index.html
Reading the docs helps here, too:
Per RFC 3986, the leading slash after the authority (host name and port) portion is treated as part of the path.
So the path is everything beginning (and including) at the slash after the authority which is www.apple.com in our case.
Question 2
Is there a time when one should be used over the other?
From the docs: (method: path)
If this URL object contains a file URL (as determined with isFileURL), the return value of this method is suitable for input into methods of NSFileManager or NSPathUtilities.
In my opinion that sentence states clearly that you should use path when you work with NSFileManager or NSPathUtilities.
Conclusion:
When you work with remote URLs you (generally) use absoluteString, otherwise the result is not what you (generally) want. When you work with local URLs use path.
Sources: http://www.ietf.org/rfc/rfc1808.txt http://www.ietf.org/rfc/rfc3986.txt NSURL Class Reference
내가 추가로 기입하는 내용
let documentsUrl = FileManager.default.urls(for: .applicationSupportDirectory, in:.userDomainMask).first!
let url = documentsUrl.appendingPathComponent("QuestionModel.sqlite")
print ("?? \(url.path) ??\n")
print ("++ \(url.absoluteString) ++\n")
위와 같은 코드를 이용하여 application support 폴더내 화일에 접근하려는 경우
url.path
?? /Users/owner/Library/Developer/CoreSimulator/Devices/7C444728-467E-4085-8E94-6298D30B68D1/data/Containers/Data/Application/055751E5-8656-4B84-AE74-99AB01522080/Library/Application Support/QuestionModel.sqlite ??
url.absoluteString
++ file:///Users/owner/Library/Developer/CoreSimulator/Devices/7C444728-467E-4085-8E94-6298D30B68D1/data/Containers/Data/Application/055751E5-8656-4B84-AE74-99AB01522080/Library/Application%20Support/QuestionModel.sqlite ++
와 같이 결과가 된다. path의 경우 space가 정상적으로 표시된다. absoluteString의 경우는 %20으로 표현된다.
0 notes
junecnol · 7 years ago
Link
original source : https://stackoverflow.com/questions/25471024/in-ios-apps-whats-the-difference-between-the-main-bundle-and-the-documents-di
the mainBundle is the installed app
it is the size of the extracted ipa (you can see that in xcode beforehand)
it is ReadOnly and won't contain user files (e.g. documents)
deleted with your app (it is the app)
when updating from the App Store, older ioses replace the whole bundle, downloading it as a whole. newer oses 6+ IIRC, do delta updates, only downloading changed files. you can't say how much is downloaded -- at least the amount of bytes you changed.
the documents dir is where your user generated contents are stored.
Its size depends on what your user/your app creates as documents ;) it starts with 0 mb
It is ReadWrite
deleted with your app
remains untouched by updates
that answers question 1 and 3 and 4
question 2 is wrong .. a filesystem folder doesn't consume memory unless files are loaded by the app/the os
the os obviously loads the necessary parts of your app and the required frameworks
your app can load documents.
memory usage is only vaguely / not really related to file size
2 notes · View notes
junecnol · 8 years ago
Video
youtube
0 notes