Re: Strange NSZombie occurring

2011-08-07 Thread Dr. Scott Steinman
Ah. I see some of your points. Very dumb of me.  I'm new to Cocoa, but I did 
program in a number of other languages for 30 years. I apologize for not being 
clear enough.  Pain and nausea tend to mess up the clarity of my thinking.  
Unfortunately, I'm ill most of the time (don't ask about my health. It's too 
depressing).  This also makes it take an extremely long time to get any program 
done.  In the past, I got into the habit of not asking for help, and forcing 
myself to figure out the solution on my own. I don't like to bother other 
people with my problems (besides, learning from my mistakes was the way I 
learned before).  Maybe with Cocoa this is a bad idea.

 Is this your exact code? You use wordsFromPhrase: here but the method below 
 is wordsInPhrase:.

This is a typo.  The same method names are used in my code. I tried to pare 
down the source code to a manageable length for posting my question.  When I 
looked at it afterwards, I didn't notice my own typos.  I always the a long 
time to check for such typos when within Xcode.

To give you a little more background about the context of the code snippets in 
the full program, I'm trying to animate the individual words of the phrase in 
sequence with fading in and out, color changes, etc. I'm using Core Animation 
in conjunction with the NSTimer because I could not find an elegant way to 
create an NSKeyframeAnimation in which each individual word of my phrase 
(displayed  in a CATextLayer) could be swapped in sync with the other 
animatable properties.  Each individual word had to be set before the animation 
started.  My solution was to use the timer's changeWords: method to change the 
words and trigger a one-shot animation on each invocation, with the timer's 
duration slightly longer than the animation's duration.  Yes, I know this is a 
kludge, but it was the only way that I could come up with to solve this 
problem.  I ran it past a few other people and they thought it would work.  Any 
other approaches would be appreciated.

 Another thing: you are ignoring the argument thePhrase.


Right.  In paring down the code for my post, I passed an argument. In my 
working code, I simply use the phrase property within the method.  Sorry about 
making that mistake and confusing the issue.  And, yes, I am declaring ivars 
for all of the properties.

 phrase = @This is the phrase to display;//  stringWithString: is almost 
 never what you intend.

God, was that stupid!  Of course I should have done that!

 Do you ever want to change .words without doing [self start]? If not, make 
 the call to -start inside setWords:. Then self.words = [self wordsFromPhrase: 
 self.phrase] can completely replace -setUp.

Good point.  Within start: I call different methods for each type of animation 
to use, but I never change the words without calling [self start]. This would 
be a good place to move that call.  I had not refactored my code yet.

  NSArray *wordArray;
  [wordArray arrayByAddingObjectsFromArray:[phrase 
 componentsSeparatedByString:@ ]];

I did not notice that mistake.  That _should_ crash. Thanks.

 and that you _really_ mean:
 @property(nonatomic, readonly) NSUInteger numWords;
 @property(nonatomic, readonly) NSArray *words;
 @property(nonatomic, retain) NSArray * backingWordsArray;

I thought that properties such as NSString and NSArray needed to be retained or 
copied.  Am I wrong?

  wordChangeTimer = [[NSTimer scheduledTimerWithTimeInterval:wordChangeInterval
 [My customary objection to accessing an ivar directly.]

I tried both wordChangeTimer and self.wordChangeTimer when I was testing the 
program. Both worked, so I left it as is.

 self.wordChangeTimer = [NSTimer ... repeats: YES];
 If you let the property manage your memory, you won't have to do it yourself. 
 And if you have a setter method, you can invalidate the old timer.

Would invalidating within the setter as the NSTimer is assign in the code above 
for the first time cause a problem?
  
 What are setUpDisplay and startDisplay? Are they the same as setUp and start?

Yeah. Another typo. You know, when I took a mandatory typing class in junior 
high school, I was the worst typist in the class.  That's probably why I was 
also a terrible piano player. 

I ran everything through the debugger, and stepped though it.  That's how I 
knew that words had a non-nil value in start and not have it in changeWords:.  
As for Instruments, I find Apple's documentation very unclear.  I've only used 
Instruments on one project before this, and managed to remove a leak.  When I 
ran Instruments on this project, I did not notice a leak. However, since I'm so 
new to Instruments, it's entirely possible that I forgot how to use it properly 
again on this project. ;-)  Is there a good tutorial on using Instruments?  All 
I've seen on-line are descriptions of the tools within Instruments, but not 
clear instructions on how to use them.

 I will take your advice and correct my code. I appreciate your 

Re: Strange NSZombie occurring

2011-08-07 Thread Dr. Scott Steinman
 Have you seen Hillegass's book on Cocoa. It's an excellent start for Cocoa 
 newbies.

I took Aaron's course about 10 years ago, but didn't have a chance to use Cocoa 
since then due to job requirements.  I lost a lot of my books recently in a 
disaster (aren't you all getting tired of knowing how crappy my life is?).  My 
wife insisted on avoiding dead tree books since then, so I only have it in 
eBook form, but it's too difficult to search.  I intend to read both Aaron's 
and Matt Neuberg's iOS books when I'm ready to try an iPad app.

 Yes, I know this is a kludge...
 
 I'm not so sure about that; sounds reasonable to me.

Thanks.  That feedback is reassuring.

Scott
Sent from my iPad





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Animating a flickering display

2011-07-04 Thread Dr. Scott Steinman
My program needs to display counterphase flickering test, i.e., one display is 
white text on a black background, and the other is black text on a white 
background, and the two displays are switched back and forth. I have concluded 
that there are two options to do this:

1. Draw each display into two NSViews, then switch back and forth between 
between them (via replaceSubview:with:) with an NSTimer to time the switches.
2. Use Core Animation to fade in one display and fade in the other.

In each case, I don't know how to avoid blocking a button presses whose action 
would stop the animation.

Which is the better way to proceed?  How do I keep the user interface 
responsive?

Please point me in the right direction.

Thank you.

Scott
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Animating a flickering display

2011-07-04 Thread Dr. Scott Steinman
The purpose of the program is to compare the visibility of the text when it is 
static versus when it flickers (so in some ways it's similar to signage).  
Therefore, I must make the text display switch back and forth between two 
displays with opposite black/white contrast to produce the flicker -- either a 
sudden swap or easing in/out are acceptable, as long as the switching back and 
forth can be repeated indefinitely at a given rate and does not block other GUI 
actions (a button press will be used to stop the animation). The smoothness of 
the font via anti-aliasing is not that important.

I hope that this is enough information to make the task more understandable.

Scott

On Jul 4, 2011, at 2:30 PM, Kyle Sluder wrote:

 On Mon, Jul 4, 2011 at 11:31 AM, Dr. Scott Steinman drstein...@me.com wrote:
 My program needs to display counterphase flickering test, i.e., one display 
 is white text on a black background, and the other is black text on a white 
 background, and the two displays are switched back and forth. I have 
 concluded that there are two options to do this:
 
 It might help to explain what you're doing in more detail. Is this for
 signage, or for testing video monitors, or what? Do you want the
 animation to ease in/out, or abruptly swap periodically? Is the text
 dynamic? Do you care about subpixel anti-aliasing?
 
 --Kyle Sluder

Scott Steinman, O.D., Ph.D.

Sent from my iPad





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com