Я очень новичок в программировании в целом. Я пытаюсь обновить UILabel «Lives» с целым сроком жизни. Однако я продолжаю получать предупреждение «результат выражения не используется» в строкеПродолжайте получать результат выражения, не использованный при попытке обновления UILabel
Lives.text = @ "", life;
//
// Game.m
// SprinklerDash
#import "Game.h"
@interface Game()
@end
@implementation Game
-(void)Walk{
Runner.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Runner1.png"],
[UIImage imageNamed:@"Runner2.png"],
[UIImage imageNamed:@"Runner3.png"],
[UIImage imageNamed:@"Runner4.png"],
[UIImage imageNamed:@"Runner5.png"],
[UIImage imageNamed:@"Runner6.png"],
[UIImage imageNamed:@"Runner7.png"],
[UIImage imageNamed:@"Runner8.png"], nil];
[Runner setAnimationRepeatCount:INFINITY];
Runner.animationDuration = .75;
[Runner startAnimating];
}
-(void)Moving{
Runner.center = CGPointMake(Runner.center.x, Runner.center.y - UpMovement);
if(CGRectIntersectsRect(Runner.frame, Water.frame)){
life = life - 1;
Lives.text = @"",life;
Runner.center = CGPointMake(Runner.center.x, Runner.center.y + 100);
}
}
-(IBAction)StartGame:(id)sender{
Start.hidden=YES;
UpMovement = 3;
[self Walk];
Movement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(Moving) userInfo:nil repeats:YES];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
В каком учебнике вы нашли синтаксис 'Lives.text = @" ", life;' ?? Взгляните на документацию NSString. (Spoiler: stringWithFormat.) –
Я видел это после немного поискового запроса. Спасибо, что направили меня в нужное место! – tomanc