Kekosavar
asked on
nstime in for statement
i want to call a method in per 5 seconds. also there is a count and after 20 seconds if the count is equal to 4 then do something..like below code..
but I see, it writes NSLog(@"denemelik"); at every 5 second not after if cnt is 5. I think it must write the "denemelik" after 25 seconds because of if (cnt == 5 )
I hope you understand what I mean..Can you help me? How can I solve this problem?
but I see, it writes NSLog(@"denemelik"); at every 5 second not after if cnt is 5. I think it must write the "denemelik" after 25 seconds because of if (cnt == 5 )
I hope you understand what I mean..Can you help me? How can I solve this problem?
for (int i=1; i<6; i++) {
[NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector:@selector(onTick:)
userInfo: nil repeats:YES];
cnt=i;
}
-(void)onTick:(NSTimer *)timer {
if(timer)
{
CLLocation *d =[[CLLocation alloc] init];
ws6=[[GetData5 alloc]init];
[ws6 GetWebservice5:@"123abc":d.coordinate.latitude:d.coordinate.longitude:0 :0:@"mesafe" ];
NSMutableArray *arr = [[NSMutableArray alloc] init];
if (cnt == 5 )
NSLog(@"denemelik");
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.