Giter Club home page Giter Club logo

Comments (1)

KangHoyong avatar KangHoyong commented on August 15, 2024

__strong & __weak 차이점

__strong : 만들어진 아이를 강하게 가지고 있다가 함수의 지역성에 의해서 if문 끝나고 stack pop 되면 메모리 삭제
ex) __strong UIImage *temp = [[UIImage alloc] init]; life cycle 관여를 합니다 강하게 참여하여 함수의 지역성에 의해서 if문 끝나고 stack pop 되면 메모리 삭제

__weak : weak 단순참조 객체가 필요해서 포인터를 객체를 가저오는경우 주소는 있는데 내가 원하는객체가 없으면 댕글링 포인터(포인터가 여전히 해제된 메모리 영역을 가리키고 있다면, 이러한 포인터를 댕글링 포인터(Dangling Pointer)라고 한다)가 발생 하지만 Zero weak 발생하여 댕글링 포인터 해결 즉 if문이 끝나면 stack pop 대상지의 주소가 없으므로 NULL처리

__unsafe_unretained :  Zero weak 발생하지 않는다. if문이 끝나도 메모리는 살아있음

__weak 사용한 경우 return 후에 메모리가 자동적으로 nill을 가지는 것을 확인할수있다.
2017-07-09 1 55 58

__unsafe_unretained 사용한 경우 return 후에 메모리가 자동적으로 nill을 가지지 않는다.
2017-07-09 1 58 37

from studyroom.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.