У меня проблема. У меня есть 2 класса «Рейтинг» (с .h и .m), «RatingViewController» (с .h и .m).
Rating.h
#import
@interface Rating : NSObject {
int usrLyrics;
int usrMusic;
int usrTotal;
}
- (void) setUsrTotal;
@end
Rating.m
#import "Rating.h"
@implementation Rating
-(void) incUsrLyrics
{
usrLyrics = 5;
}
- (void) incUsrMusic {
usrMusic = 6;
}
- (void) setUsrTotal {
usrTotal = usrMusic + usrLyrics;
}
}
@end
RatingViewController.h
@interface RatingItudeViewController : UIViewController {
Rating *rating;
}
- (IBAction) submitRating;
RatingViewController.m
#import "RatingItudeViewController.h"
@implementation RatingItudeViewController
- (IBAction) submitRating {
[rating setUsrTotal];
NSLog(@"usrTotal is %i", [rating usrTotal]);
}
@end
Это выглядит просто, но не работает, в консоли всегда "usrTotal равен 0".
Помогите мне, пожалуйста.
ОБНОВЛЕНО
Только сейчас я добавляю пару строк в RatingViewController.m
- (IBAction) submitRating {
[rating incUsrMusic];
[rating incUsrLyrics];
[rating setUsrTotal];
NSLog(@"usrTotal is %d", [rating usrTotal]);
}
и в Rating.h
-(void) incUsrLyrics;
- (void) incUsrMusic;
- (void) setUsrTotal;
- (int) usrTotal;
А при нажатии кнопки в консоли снова «usrTotal is 0».