티스토리 뷰
I think you will agree with this following sentence.
If you want to create new initialiser with some parameter, please don't forget to call '[super init];'.
For example,
- (instancetype)initWithString:(NSString *)string
{
self = [super init];
if (self) {
self.text = string;
}
return self;
}
And now, do you agree with the written code? May be you found already the problem.
In this case, I preffer to call '[self init];'' like following code.
- (instancetype)initWithString:(NSString *)string
{
self = [self init];
if (self) {
self.text = string;
}
return self;
}
because if there can be some initialising in 'init'.
This code will guarantee that your code will not miss some initialising process for this interface.
Someone can make some argument.
"If super class has already that method, you have to call '[super initWithString:];'"
Yes totally right. and in that initialiser of super class, it has to call '[self init];'.
'programming' 카테고리의 다른 글
pod install error case (0) | 2015.01.26 |
---|---|
[iOS] How to remove a notification programmatically from iOS Notification Center. (0) | 2015.01.22 |
CocoaPods Error with XCode6 (0) | 2014.11.05 |
Git Log : print merge tree (0) | 2013.11.10 |
[It's not But!! update 2013.08.09] KIWI (BDD/TDD Framework) seems like to have a bug (3) | 2013.05.23 |
- Total
- Today
- Yesterday
- 독일 구직
- IFA 2011
- mixnstand
- 교육
- windows mobile
- It
- CocoaPods
- 세부
- 호핑투어
- Programing
- 김봉두
- Blue Card
- UbiVelox
- 필리핀
- idle
- 교사
- 학교
- 블루카드
- 독일
- 호핑
- ios
- mobile
- 독일 이민
- 독일 IT
- demo application
- 사무실
- IFA
- widget
- 독일이민
- 커피
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |