iphone getting hours/min/seconds app crashes.
Posted
by coure06
on Stack Overflow
See other posts from Stack Overflow
or by coure06
Published on 2010-05-29T07:02:15Z
Indexed on
2010/05/29
7:12 UTC
Read the original article
Hit count: 215
objective-c
|iphone-sdk
i have this code in my overridden drawRect method
NSDate *date = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
unsigned int unitFlags = NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit;
NSDateComponents *comp = [calendar components:unitFlags fromDate:date];
NSInteger h = [comp hour];
NSInteger m = [comp minute];
NSInteger s = [comp second];
NSLog(@"%i,%i,%i", h,m,s);
NSLog(@"test");
[date release];
[calendar release];
[comp release];
I am calling drawRect using setNeedsDisplay from my custom method (timer based after each 1 secon). It runs only once and then app exit automatically. If i comment out all the code and just write
NSLog(@"test");
then application works ok, it logs "test" after each 1 sec.
© Stack Overflow or respective owner