내 헤더iOS에서 0이 아닌 초기 값을 설정하는 방법은 무엇입니까?
@interface MyClass : UIView{
int thistone;}
- (IBAction)toneButton:(UIButton *)sender;
@property int thistone;
@end
에서 언급 된 바르를하고 난 구현에 합성 한 :
@implementation MyClass
@synthesize thistone;
- (IBAction)toneButton:(UIButton *)sender {
if(thistone<4)
{thistone=1000;} // I hate this line.
else{thistone=thistone+1; }
}
내가 찾을 수없는 (또는 매뉴얼에서 찾을 수)를 설정하는 방법을 0이 아닌 초기 값 나는 그것을 1000에서 시작하고 버튼을 누를 때마다 1 씩 증가 시키길 원합니다. 이 코드는 내가 의도 한 바를 정확히 수행하지만 위의 if/else 문을 저장하는 더 적절한 방법이 있다고 생각합니다. 온라인 문서의 특정 줄에 대한 코드 수정 또는 포인터가 크게 감사드립니다.
당신은 초기화 * 방법을 사용해야합니다. 이 답변을 참조하십시오 : http://stackoverflow.com/questions/4579342/where-to-initialize-custom-uiview-instantiated-in-inter-builder – abellina