Peace , my eXercice is to make the application connect , send and receive data to remote webserver and this is every 10 Secondes so idea goes to work with NSTimer and adding it into a runLoop , but the connection is established only once and then then ( in the next 10 seconds ) the app Crashes . Here is my Code , THANK YOU for HELPING .
#define HTTP_CONTACT_TIMEOUT 10.0
@implementation HTTPEXERCICEAppDelegate
@synthesize window;
@synthesize HttpConnTimer;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self->HttpConnTimer =
[NSTimer scheduledTimerWithTimeInterval:HTTP_CONTACT_TIMEOUT target:self selector:@selector(Contact:) userInfo:NULL repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:self->HttpConnTimer forMode:NSRunLoopCommonModes];
return YES;
}
-(void) Contact:(NSTimer*)ttimer {
NSAutoreleasePool *Pool = [[NSAutoreleasePool alloc] init];
HTTP_Comm *HTTPClient = [[HTTP_Comm alloc] init];
[HTTPClient CommunicateWith:@"http://someURL"];
[HTTPClient release];
[Pool release];
}