Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3. Light the candle Application access method changed property #3

Open
KangHoyong opened this issue Jul 9, 2017 · 0 comments
Open
Assignees

Comments

@KangHoyong
Copy link
Owner

KangHoyong commented Jul 9, 2017

property using

  • Light the candle Application access method changed property Code

  • @interface CandleModel : NSObject -> NSObject 최상의 객체 상속을 위해서 Interface 정의

  • property 선언하면 알아서 멤버 변수 선언 및 get set 정의부분 선언 할시 자동으로 구현부분 생성됨 모던 런타임에서만

  • @Property 사용 이득 -> synthesize 를 이용하여 get set 자동으로 정의
     

  • 기존 old 방식의 access method 선언
    1 외부에서 접근할수 있도록 access method 선언 (getter setter 추가)
      - (UIImage *) imageCandleOn; // getter
      - (void) setImageCnadleOn:(UIImage *)newImage; // setter
    하지만 여기서 property 로 선언하면 다음과 같음
    @Property (nonatomic, strong) UIImage *ImageCadlOn ; // getter , setter 선언  

First type option @Property (type, type)

  • nonatomic ( Singer Thread)
  • atomic : 멤버 접근안에 뮤텍스 설정 (멤버 접근에서만 사용 Multi Thread)

Second type option

  • weak , retain , copy , assing , strong : copy를 제외한 나머지는 동일
    Copy 경우는 Copy set에 대해서 인자값이 넘어오는 인자에대해서 Copy 수행

  • retain = strong , assing = strong

get Name 옵션 getter = name setter = name
@Property (nonatomic, strong, getter = name , setter = name) UIImage *ImageCadlOn ; // getter , setter 선언  

getter만 만들경우 옵션 readonly
 @Property (nonatomic, readonly, getter = name) UIImage *ImageCadlOn ; // getter , setter 선언

구현 부분
//@synthesize ImageCandlOn; 선언 하면 끝 하지만 이마저도 ios버전이 업데이트 후 자동으로 구현 되므로 필요 없음 하지만 개인이 필요시 수정이 필요하다면
||- (UIImage *) imageCandleOn
  {
  return imageCandleOn;
  }
  -(void) setImageCnadleOn:(UIImage *)newImage
  {
  imageCandleOn = newImage;
  }
이런식으로 수동으로 자기가 만들어서 사용할 수 도 있다.

 - 자료출저

@KangHoyong KangHoyong self-assigned this Jul 9, 2017
@KangHoyong KangHoyong changed the title 3. Light the candle MVC and property 3. Light the candle access method changed property Jul 9, 2017
@KangHoyong KangHoyong changed the title 3. Light the candle access method changed property 3. Light the candle Application access method changed property Jul 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant