임 NScimer에 대해 배우고 문서를 읽은 후 간단한 테스트를했습니다. 나의 이해는 viewDidLoad를 main에서 호출 할 때 viewDidLoad는 3.0 초 후에 runTest를 호출해야하지만 작동하지 않는다는 것입니다. 그것은 오류없이 잘 컴파일하지만 runTest (NSLog 없음)로드하지 않습니다 도와주세요 ... 고마워요.간단한 NSTimer 테스트가 작동하지 않습니다.
#import "MyClass.h"
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MyClass *trial = [[MyClass alloc]init];
[trial viewDidLoad]; ///// this should call viewDidLoad /////
[pool drain];
return 0;
}
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
NSTimer *aTimer;}
@property (nonatomic, retain) NSTimer *aTimer;
- (void)viewDidLoad;
- (void)runTest;
@end
#import "MyClass.h"
@implementation MyClass
@synthesize aTimer;
- (void)viewDidLoad {
aTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(runTest) userInfo:nil repeats:NO];}
- (void) runTest {
NSLog(@"Working - runTest has loaded !");
aTimer = nil;
}
@end
viewDidLoad를 호출 하시겠습니까? – jbat100