Strange NSZombie occurring
Strange NSZombie occurring
- Subject: Strange NSZombie occurring
- From: Scott Steinman <email@hidden>
- Date: Sun, 07 Aug 2011 08:10:39 -0500
I've got a zombie appearing in the weirdest place in my program. Here is the relevant part of the code, using generic names for the methods:
-(void)setUp;
-(void)start;
-(void)changeWords:(NSTimer*)theTimer;
-(NSArray *)wordsInPhrase:(NSString *)thePhrase;
@property (nonatomic, assign) int numWords;
@property (nonatomic, assign) NSUInt wordChangeInterval;
@property (nonatomic, copy) NSString *phrase;
@property (nonatomic, copy) NSArray *words;
@property (nonatomic, copy) NSTimer *wordChangeTimer;
…
- (id)init
{
self = [super init];
if (self) {
phrase = [[NSString stringWithString:@"This is the phrase to display"] retain];
wordChangeInterval = 0.2;
}
return self;
}
-(void)setUp
{
words = [[self wordsFromPhrase:phrase]] retain];
[self start];
}
-(NSArray *)wordsInPhrase:(NSString *)thePhrase
{
NSArray *wordArray;
[wordArray arrayByAddingObjectsFromArray:[phrase componentsSeparatedByString:@" "]];
numWords = [wordArray count];
return wordArray;
}
- (void) start
{
currentWordIndex = 0;
wordChangeTimer = [[NSTimer scheduledTimerWithTimeInterval:wordChangeInterval
target:self
selector:@selector(changeWords:)
userInfo:nil
repeats:YES] retain];
}
- (void)changeWords:(NSTimer*)theTimer
{
currentWordIndex += 1;
if (currentWordIndex > numWords)
currentWordIndex = 0;
messageLayer.string = [self.words objectAtIndex:currentWordIndex];
}
Now, the strangeness: words exists and is OK in setUpDisplay and startDisplay in that it contains the right words from the phrase. But in changeWords:, somehow words is nil. I'm at a loss to figure out how words could be released between start and changeWords:. I'd appreciate some help.
Thanks.
Scott
Dr. Scott Steinman
Brought to you by a grant from the Steinman Foundation (Thanks, Mom and Dad!)
Recommended by Major University Studies Over the Leading Brand
drsteinman at comcast dot net
I hope I die peacefully in my sleep like my grandfather. . .not screaming in terror like his passengers. -- "Deep Thoughts", Jack Handy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden