:) Key words were 'new to Obj-C' and that the sequence worked fine if
it started but not after it cleared. You can take a look at what
actually is happening in runAction (namely, the action is being stored
into an NSMutableArray), and understand that NSMutableArray
automatically applies a 'retain' message to objects that are added to
it, and sends a 'release' message to these objects when they are
removed.
I'd say codemattic's advice is very key.. the built in dot notation is
super awesome for release/retain stuff.
One thing to note though on this that is necessary:
say you have Action *runAction with all the property/synthesize done up.
'
-(void) doStuff
{
runAction = [Animate actionWith....]
}
will *not* actually use the retain/release automatically. you need to use
-(void) doStuff
{
self.runAction = [Animate actionWith....]
}
that 'self.' is important.
'
Chris.
On Sat, Jun 20, 2009 at 12:04 PM,
<cocos2d-iphone-discuss@gamesforfood.cl> wrote:
> codemattic says:
>
> First of all, psionic - nice catch!
>
> oskob,
>
> Dont use id's unless you need to. Give the compiler as much information as
> you can. Also use properties, and then use dot notation so the compiler can
> worry about correct retain/release for member variables. Remember in
> -dealloc to set them to nil.
>
> .h-file:
>
> AtlasSprite * sprite;
> Action * runAction;
> Action * standAction;
>
> @property(readwrite,retain) Action * runAction;
> @property(readwrite,retain) Action * standAction;
>
> .m-file:
>
> @implementation MyClass
>
> @synthesize runAction;
> @synthesize standAction;
>
> ...
>
> self.runAction = [RepeatForever actionWithAction: myRepeatingAction];
>
> Its great that psionic figured it out from the snippet you posted - even
> though the error wasnt in your example. If you have a problem with your
> code, dont post a small snippet, try and post the smallest full example of
> whats making you crash. Step through your code and find at what line you are
> crashing - then check the console and post what error you are getting - just
> saying "it crashes" is pretty vague.
>
> Read the whole thread.