问题
I'm trying to display an array of numbers in a UILabel using a timer,and show them in the order set in the array, but I only receive the Title in the format and then a SIGABRT ! any suggestions...Thanks
Part of the code with problems!
-(IBAction) rotate3
{
NSString *number = [dayArray initWithArray:(NSArray *)dayArray];
NSArray *array = [[NSArray alloc] initWithObjects: @"0", @"1", @"2", @"3", @"4", @"5" ,@"6", @"7", @"8",@"9",@"10",@"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18", @"19",nil];
numberCount++;
timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(rotate3 )userInfo:nil repeats:YES];
self.dayArray = array;
[array release];
label.text = [[NSString alloc] initWithFormat:@"Day %@ " number];
}
回答1:
It is very strange string : [dayArray initWithArray:(NSArray *)dayArray];
. Try this:
-(IBAction) rotate3
{
NSString *number = [self.dayArray description];
NSArray *array = [[NSArray alloc] initWithObjects: @"0", @"1", @"2", @"3", @"4", @"5" ,@"6", @"7", @"8",@"9",@"10",@"11",@"12",@"13", @"14", @"15", @"16", @"17", @"18", @"19",nil];
numberCount++;
timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(rotate3 )userInfo:nil repeats:YES];
self.dayArray = array;
[array release];
label.text = [NSString stringWithFormat:@"Day %@ ", number];
}
回答2:
Your SIGABRT is probably due to stack corruption: NSTimer can only be used with selectors of the form:
- (void)myTimerFireMethod: (NSTimer *)timer;
but you're trying to use it with
- (void)rotate3;
which doesn't take enough arguments.
来源:https://stackoverflow.com/questions/8018688/how-to-display-an-nsarray-in-a-uilabel-and-use-timer