0
我想在我的UIViewController中设置一个数组。笔尖被加载到我的应用程序,有时反复。我将此添加到我的initWithNibName中以初始化阵列在initWithNibName中初始化一个数组
NSMutableArray *temp = [[NSMutableArray alloc] initWithObjects:@"one",@"two",@"three",@"four",@"five",nil];
[self setScoreArray:temp];
[temp release];
scoreArray是具有合成属性的MutableArray。当我去访问viewDidLoad中的数组时,我将[[self scoreArray] count]设置为0.另外,当我重复加载笔尖时,出现访问错误。有什么建议么?我错过了一个步骤。谢谢。我合成属性为阵,在我的类声明:
NSMutableArray *_scoreArray;
然后
@property (nonatomic, retain) NSMutableArray *scoreArray;
我在执行
@synthesize scoreArray =_scoreArray;
,并在我的dealloc
然后
[_scoreArray release], _scoreArray = nil;
我正在编辑这篇文章给s怎么怎么,我加载的笔尖与我的RootViewController的
- (void) createNewSlide:(NSInteger)slideIndex {
NSDictionary *slideObj = (NSDictionary *)[[self slidesDataSource] objectAtIndex:slideIndex - 1];
NSString *currentTitle = [slideObj objectForKey:@"title"];
[[self slideTitle] setText:currentTitle];
NSString *currentContent = [slideObj objectForKey:@"contentString"];
NSString *currentContentType = [slideObj objectForKey:@"contentType"];
if ([self currentVC] != nil) {
[[self currentVC] reset];
[self setCurrentVC:nil];
}
if ([currentContentType isEqualToString:@"slide"])
{
[[self containerViewController] loadImage:currentContent];
}
else if ([currentContentType isEqualToString:@"quiz"])
{
NSInteger quizNum = [[slideObj objectForKey:@"quizNum"] integerValue];
NSLog(@"%s%@%d",__FUNCTION__,@"quizNum ",quizNum);
QuizViewController *quizView = [[QuizViewController alloc] initWithNibName:@"QuizViewController" bundle:nil];
[self setCurrentVC:quizView];
[quizView release];
[[self containerViewController] replaceSlideWithViewController:[self currentVC]];
}
else if ([currentContentType isEqualToString:@"PIDView"])
{
PIDViewController *PIDView = [[PIDViewController alloc] initWithNibName:@"PIDView" bundle:nil];
[self setCurrentVC:PIDView];
[PIDView release];
[[self containerViewController] replaceSlideWithViewController:[self currentVC]];
}
else if ([currentContentType isEqualToString:@"LoginView"])
{
LoginViewController *login = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil];
[self setCurrentVC:login];
[login release];
[[self containerViewController] replaceSlideWithViewController:[self currentVC]];
}
else if ([currentContentType isEqualToString:@"VakView"])
{
VakViewController *vakView = [[VakViewController alloc] initWithNibName:@"VakView" bundle:nil];
[self setCurrentVC:vakView];
[vakView release];
[[self containerViewController] replaceSlideWithViewController:[self currentVC]];
}
else if ([currentContentType isEqualToString:@"PlanView"])
{
PlanViewController *planView = [[PlanViewController alloc] initWithNibName:@"PlanView" bundle:nil];
[self setCurrentVC:planView];
[planView release];
[[self containerViewController] replaceSlideWithViewController:[self currentVC]];
}
感谢您的见解。 PlanView是导致问题的原因之一。但它不是在加载时,而是在其他东西加载之后。我运行了分析器,它报告没有内存泄漏。 顺便说一句,currentVC是一个综合性质。
你如何声明`scoreArray`属性?你是否包含`retain`指令?否则我相信默认是`assign`。 – 2011-01-27 00:58:41