<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Forum: iPhone SDK / UIKit / Objective-C / Xcode - Recent Posts</title>
		<link>http://www.cocos2d-iphone.org/forum/forum/8</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 00:36:04 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/forum/8" rel="self" type="application/rss+xml" />

		<item>
			<title>greenTeaGames on "Spell Checking with UITextChecker"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29102#post-143528</link>
			<pubDate>Thu, 09 Feb 2012 23:21:11 +0000</pubDate>
			<dc:creator>greenTeaGames</dc:creator>
			<guid isPermaLink="false">143528@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Steve,</p>
<p>You were right, that was the problem. And you are also right about my lack of knowledge. I'll go hit up Apple's dev library for a few days. Thank you for your help (^_^)
</p></description>
		</item>
		<item>
			<title>Steve Oldmeadow on "Spell Checking with UITextChecker"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29102#post-143404</link>
			<pubDate>Thu, 09 Feb 2012 06:59:08 +0000</pubDate>
			<dc:creator>Steve Oldmeadow</dc:creator>
			<guid isPermaLink="false">143404@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>It doesn't look like you created an instance of UITextChecker e.g [[UITextChecker alloc] init].  That means textChecker is nil, you can still call methods on it but they'll return nil or 0.  The code you posted is just declaring a variable called textChecker it doesn't create an instance of it.</p>
<p>If you don't understand this stuff (as you admit) you should.  It is boring but if you don't take the time to learn it now the time will be taken from you in the future.  How much time have you already wasted on this issue?  Things will only get worse.
</p></description>
		</item>
		<item>
			<title>greenTeaGames on "Spell Checking with UITextChecker"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29102#post-143402</link>
			<pubDate>Thu, 09 Feb 2012 06:19:56 +0000</pubDate>
			<dc:creator>greenTeaGames</dc:creator>
			<guid isPermaLink="false">143402@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Update: Interestingly, when I put the instantiation of the "textChecker" variable in the implementation file (as opposed to the header file), I get an EXEC_BAD_ACCESS in CCNode.m:</p>
<pre><code>+(id) node
{
	return [[[self alloc] init] autorelease];  //EXEC_BAD_ACCESS on this line.
}</code></pre>
<p>Could it be that I'm not allocating or retaining this non CC object properly? To be honest, I still don't understand variable retainment and all that.</p>
<p>UPDATE 2: Doing the following fixes the exec_bad_access, but the spell check still does not work correctly:<br />
<pre><code>UITextChecker* textChecker = [[UITextChecker alloc] autorelease];</code></pre>
<p>Now I get "no errors, YAY" every time, even when there are spelling errors in the string!
</p></description>
		</item>
		<item>
			<title>greenTeaGames on "Spell Checking with UITextChecker"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29102#post-143395</link>
			<pubDate>Thu, 09 Feb 2012 04:33:21 +0000</pubDate>
			<dc:creator>greenTeaGames</dc:creator>
			<guid isPermaLink="false">143395@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey, I'm trying to come up with a way to use UITextChecker to see if a word is a real word or not. This is for a word game I'm thinking of making, but I'm having trouble working with this class.</p>
<p>Here is a simple test that I made to see if UITextChecker worked or not:</p>
<p>In the init method of HelloWorldLayer.m of a fresh chipmunk physics template:<br />
<pre><code>// Spell check test:
        NSString* string1 = [NSString stringWithString:@&#34;This is a string with a misssspelled word.&#34;];
        NSString* preferredLang = [[UITextChecker availableLanguages] objectAtIndex:0];
        misspelledWord = [textChecker rangeOfMisspelledWordInString:string1 range:NSMakeRange(0, string1.length) startingAt:0 wrap:NO language:preferredLang];

        if (misspelledWord.location == NSNotFound) {
            NSLog(@&#34;No errors, YAY!&#34;);
        }
        else {
            NSLog(@&#34;String1: %@&#34;, string1);
            NSLog(@&#34;Mispelled word with location: %d, and length: %d&#34;, misspelledWord.location, misspelledWord.length);
        }</code></pre>
<p>and this in HelloWorldLayer.h:<br />
<pre><code>@interface HelloWorldLayer : CCLayer
{
	cpSpace *space;

    // Spell Check test variables:
    UITextChecker* textChecker;
    NSRange misspelledWord;
}</code></pre>
<p>I also imported these files in the header:<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#60;UIKit/UIKit.h&#62;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#60;UIKit/UITextChecker.h&#62;</code></pre>
<p>Other than these snippets, I have not changed the template at all. And this is what the console gives me:</p>
<p>Initializing Chipmunk v5.3.5 (Debug Enabled)<br />
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks<br />
2012-02-09 13:23:49.650 spell test and physics test[4902:10a03] String1: This is a string with a misssspelled word.<br />
2012-02-09 13:23:49.651 spell test and physics test[4902:10a03] Mispelled word with location: 0, and length: 0</p>
<p>I get the same result with no misspelled words. If anyone can tell me what I'm doing wrong, it would be greatly appreciated.</p>
<p>cocos2d version: 1.0.1<br />
Xcode version: 4.2
</p></description>
		</item>
		<item>
			<title>iUridium on "Cocos2D for Xcode 4.2.1"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29036#post-143221</link>
			<pubDate>Wed, 08 Feb 2012 07:28:20 +0000</pubDate>
			<dc:creator>iUridium</dc:creator>
			<guid isPermaLink="false">143221@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Cannot wait to see what @<a href='http://www.cocos2d-iphone.org/forum/profile/20192'>birkemose</a> will say on this post ;-)
</p></description>
		</item>
		<item>
			<title>marcopaivaf on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-143189</link>
			<pubDate>Wed, 08 Feb 2012 02:43:26 +0000</pubDate>
			<dc:creator>marcopaivaf</dc:creator>
			<guid isPermaLink="false">143189@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>wow, thank you so much for the explanation, its helping a lot to undestanding Object-c.<br />
Now i fixed the problem and everything is working! I will definetly study the basics a little more!</p>
<p>thank you again! I really appreciate!
</p></description>
		</item>
		<item>
			<title>fcoronel on "Cocos2D for Xcode 4.2.1"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29036#post-143186</link>
			<pubDate>Wed, 08 Feb 2012 02:22:32 +0000</pubDate>
			<dc:creator>fcoronel</dc:creator>
			<guid isPermaLink="false">143186@http://www.cocos2d-iphone.org/forum/</guid>
			<description><br /></description>
		</item>
		<item>
			<title>Thomvis on "Apple Individual developer account on more then 1 computer."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29027#post-143152</link>
			<pubDate>Tue, 07 Feb 2012 22:05:33 +0000</pubDate>
			<dc:creator>Thomvis</dc:creator>
			<guid isPermaLink="false">143152@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>As far as I know, there is no restriction on the number of computers you can use for development. There is however a max on the number of iOS devices you can debug on, namely 100.
</p></description>
		</item>
		<item>
			<title>NoobShader on "Apple Individual developer account on more then 1 computer."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29027#post-143141</link>
			<pubDate>Tue, 07 Feb 2012 21:35:41 +0000</pubDate>
			<dc:creator>NoobShader</dc:creator>
			<guid isPermaLink="false">143141@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>If I enabled a apple individual developer account on one computer inorder to make iOS apps, can I use it on another computer, or do I have to disable it before use.
</p></description>
		</item>
		<item>
			<title>Scryb on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142987</link>
			<pubDate>Tue, 07 Feb 2012 04:41:08 +0000</pubDate>
			<dc:creator>Scryb</dc:creator>
			<guid isPermaLink="false">142987@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Well now we know the problem at least. You are not doing what you want to do at all. Subclassing HelloWorldLayer gives your Enemy class its OWN enemyArray ivar, not access to some other object's ivar.</p>
<p>What you need to do is, first stop subclassing HelloWorldLayer. Then you have to properly initialize your Enemy objects – if you don't call [super init] you will not get basic object properties that come from NSObject. You always, ALWAYS have to call [super init] in any init methods, otherwise your class will not work at all.</p>
<p>What I suggest you do later, if you want the Enemy objects to have a reference to the HelloWorldLayer, is to make a Delegate variable in Enemy, and change your init method to: -(id)initWithScene:(HelloWorldLayer*)stage secound:(char)qualTipo</p>
<p>See the change? You are already trying to send the HelloWorldLayer object as an argument to each new Enemy, so why not do that properly?</p>
<p>And then we move on to your other problems...</p>
<p>Making the Enemy objects control themselves instead of the HelloWorldLayer control them is probably not the best coding strategy, it would make a lot more sense to create them and then let the HelloWorldLayer change their positions and delete them when ready.</p>
<p>And another thing: Why are you writing (arc4random() % (3-1+1)) + 1; and so on instead of arc4random() % 3 + 1;? There is no difference except confusion in the first case...</p>
<p>I really think you need to go back and study the basics a little more. Say, Apples guide to Objective C and some super beginner cocos2d tutorials. You are messing up in ways that are just too fundamental, it will not help you learn to struggle like this.
</p></description>
		</item>
		<item>
			<title>pfg2009 on "Testing &quot;release&quot; builds in Xcode 4"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28870#post-142958</link>
			<pubDate>Mon, 06 Feb 2012 23:47:49 +0000</pubDate>
			<dc:creator>pfg2009</dc:creator>
			<guid isPermaLink="false">142958@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Alright, here is a "solution" that does the trick for me.</p>
<ul>
<li>In your project "Info" tab, duplicate the default "release" configuration and call it "distribution"</li>
<li>Under "Build Settings" for your target, set the signing of the "release" build to use your "developer" profile and ensure that the signing of the "distribution" build uses your "distribution" profile</li>
<li>In the same build settings, make sure that "Validate Built Product" for "release" is set to "No" and for "distribution" is set to "Yes"</li>
<li>Manage your build schemes and duplicate the default build scheme for your target, renaming it to "&#60;blah&#62; Release"</li>
<li>Edit this new build scheme and set the build configuration for "Run &#60;blah&#62;" to "release"</li>
<li>Edit the original build scheme <strong>as well as</strong> the new build scheme and set the build configuration for "Archive" to "distribution"</li>
</ul>
<p>.<br />
Now, if you want to test a debug build on your development device, compile and run using the "&#60;blah&#62;" scheme.  If you want to test a release build on your development device, compile and run using the "&#60;blah&#62; Release" scheme.  When you want to create a distribution build, choose "Archive" from the menu as you normally would.  No more pesky, irrelevant warnings.</p>
<p>Tadaaaa!  :)
</p></description>
		</item>
		<item>
			<title>marcopaivaf on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142956</link>
			<pubDate>Mon, 06 Feb 2012 23:44:21 +0000</pubDate>
			<dc:creator>marcopaivaf</dc:creator>
			<guid isPermaLink="false">142956@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Im subclassing HelloWorldLayer because i wanted to have acess of the enemyArray inside the Enemy class so when the enemy finished his action he could destroy himself and take him out of the enemyArray, or at least i wanted to be able to call a function of HelloWorldLayer from the Enemy passing self as the enemy object, so i could destroy it and take him out of enemyArray.</p>
<p>I just got object-c to study, so i dont know another good way to do that... if it is, i will appreciate any suggestion =)
</p></description>
		</item>
		<item>
			<title>andrew on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142955</link>
			<pubDate>Mon, 06 Feb 2012 23:21:53 +0000</pubDate>
			<dc:creator>andrew</dc:creator>
			<guid isPermaLink="false">142955@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You aren't calling <code>[super init]</code> in your enemy class.</p>
<p>However, looking at your init code, calling it would make an infinite loop, since HelloWorldLayer's init initializes an Enemy class, which calls super init, which makes another Enemy class, etc. Why are you subclassing HelloWorldLayer anyway?
</p></description>
		</item>
		<item>
			<title>marcopaivaf on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142952</link>
			<pubDate>Mon, 06 Feb 2012 22:59:04 +0000</pubDate>
			<dc:creator>marcopaivaf</dc:creator>
			<guid isPermaLink="false">142952@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hey guys, thanks for the help, but i still couldn't fix it.<br />
It tried to put some NSLog to see if my HelloWorldLayer class was initializing from the actual init method, but the NSLog from the init method of the HelloWorldLayer is always the first to show up.<br />
i also tried to instantiate the enemyArray like this: enemyArray = [[NSMutableArray alloc] retain];<br />
But then, i always get the Thread 1: SIGABRT at the Main.m<br />
I didnt change anything from the AppDelegate class, or even from the others auto-created classes, like Main.m,  from the HelloWorld project of cocos2d.</p>
<p>here is the interface class of the HelloWorldLayer</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;cocos2d.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#60;Foundation/Foundation.h&#62;

// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
{
    NSMutableArray *enemyArray;

}

// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;
+(CGSize) getWinSize;
-(void)createEnemies;
-(void)destroyItemFromArray;

@end</code></pre>
<p>And here if the whole implementation of it:<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;HelloWorldLayer.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;Enemy.h&#34;

// HelloWorldLayer implementation
@implementation HelloWorldLayer

+(CCScene *) scene
{
	// &#039;scene&#039; is an autorelease object.
	CCScene *scene = [CCScene node];

	// &#039;layer&#039; is an autorelease object.
	HelloWorldLayer *layer = [HelloWorldLayer node];
	// add layer as a child to scene
	[scene addChild: layer];

	// return the scene
	return scene;
}

// on &#34;init&#34; you need to initialize your instance
-(id) init
{
	// always call &#34;super&#34; init
	// Apple recommends to re-assign &#34;self&#34; with the &#34;super&#34; return value
	if( (self=[super init])) {

        enemyArray = [[NSMutableArray alloc] init];

       [self createEnemies];

	}
	return self;
}

-(void)createEnemies{

    for(int i=0; i&#60;10; i++){

        Enemy *inimigo = [[Enemy alloc] initWithScene:self secound:&#039;c&#039;];
        [inimigo iniciar];
        [enemyArray addObject:inimigo];

    }

}

+(CGSize)getWinSize{
    // ask director the the window size
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    return winSize;
}

-(void)destroyItemFromArray{
    if(enemyArray == nil){
        NSLog(@&#34;THIS ARRAY IS NULL!&#34;);
    }else{
        NSLog(@&#34;ITS NOT NULL!&#34;);
    }
}

// on &#34;dealloc&#34; you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)

  //  [enemyArray release];
	// don&#039;t forget to call &#34;super dealloc&#34;
	[super dealloc];
}
@end</code></pre>
<p>Here is the interface of Enemy class:</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;HelloWorldLayer.h&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#60;Foundation/Foundation.h&#62;

@interface Enemy : HelloWorldLayer{
@private
    char tipo;
    CCLayer *main;
    CCSprite *sprite;

}
-(id)initWithScene:(CCLayer*)stage secound:(char)qualTipo;
-(void)iniciar;
-(void)randomPos;
-(void)setDificult;
-(void)moveEnemy:(int)tempo;
-(void)destroyObject:(id)alvo;

@property (copy)CCSprite *sprite;
@property char tipo;

@end</code></pre>
<p>And here is the implementation of it:</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;Enemy.h&#34;

@implementation Enemy

@synthesize sprite;
@synthesize tipo;

-(id)initWithScene:(CCLayer*)stage secound:(char)qualTipo{

    if(self){

        main = stage;
        tipo = qualTipo;
    }

    return self;
}

-(void)iniciar{

    sprite = [CCSprite spriteWithFile:@&#34;Enemy.png&#34;];
    [main addChild:sprite];

    [self randomPos];
    [self setDificult];
}

-(void) randomPos{

    int posX = 400;
    int posY = (arc4random() % (320-0+1)) + 0;

    sprite.position = ccp(posX, posY);

}

-(void)setDificult{

    int tempo;

    switch(tipo){
        case &#039;a&#039;:
            tempo = (arc4random() % (3-1+1)) + 1;
            break;
        case &#039;b&#039;:
            tempo = (arc4random() % (5-2+1)) + 2;
            break;
        case &#039;c&#039;:
            tempo = (arc4random() % (7-3+1)) + 3;
            break;
    }

    [self moveEnemy:tempo];

}

-(void)moveEnemy:(int)tempo{

    CCMoveTo *moveTo = [CCMoveTo actionWithDuration:tempo position:ccp(20, sprite.position.y)];
    CCCallFuncN *callBack = [CCCallFuncN actionWithTarget:self selector:@selector(destroyObject:)];

    [sprite runAction:[CCSequence actions:moveTo, callBack, nil]];
}

-(void)destroyObject:(id)alvo{
  //  [main removeChild:sprite cleanup:YES];

    //[self.enemyArray removeObject:sprite];

    [self destroyItemFromArray];

 //   [self release];

}

@end</code></pre></description>
		</item>
		<item>
			<title>Scryb on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142822</link>
			<pubDate>Mon, 06 Feb 2012 06:33:15 +0000</pubDate>
			<dc:creator>Scryb</dc:creator>
			<guid isPermaLink="false">142822@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hmm, I could've sworn it would've errored, but ok I take your word for it :)</p>
<p>But as for the second part: He did say he can log createEnemies and get an output, so obviously init must be getting called too if createEnemies is getting called.</p>
<p>Can you tell us how you are calling destroyItemFromArray and how you are creating and accessing the HelloWorldLayer?
</p></description>
		</item>
		<item>
			<title>slembcke on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142817</link>
			<pubDate>Mon, 06 Feb 2012 05:38:12 +0000</pubDate>
			<dc:creator>slembcke</dc:creator>
			<guid isPermaLink="false">142817@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/34101'>scryb</a><br />
Calling a method on nil is not an error, it simply does nothing and returns 0, nil or stack garbage depending on what type the method is supposed to return. It tends to be a silent error that just makes things fail later.</p>
<p>My best guess is that your init method is not actually being called. Like if you are another initWithMoreStuff: method defined in a superclass and expecting init to get called (it shouldn't be unless it's the designated initializer). Put a log statement in init to double check.
</p></description>
		</item>
		<item>
			<title>Scryb on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142811</link>
			<pubDate>Mon, 06 Feb 2012 05:11:44 +0000</pubDate>
			<dc:creator>Scryb</dc:creator>
			<guid isPermaLink="false">142811@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>No, don't confuse him. He's already retaining it by calling alloc/init. If he also called retain on it the retain count would be 2. Besides, it would throw an exception in the createEnemies method when trying to add the object if enemyArray was already nil there.</p>
<p>I don't see a problem here. Maybe there's a problem in the other method, or in the class that calls the method that's supposed to access the array. It's very hard to tell from only this code.
</p></description>
		</item>
		<item>
			<title>skyhawk on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142810</link>
			<pubDate>Mon, 06 Feb 2012 04:40:16 +0000</pubDate>
			<dc:creator>skyhawk</dc:creator>
			<guid isPermaLink="false">142810@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>you need to retain your array in your init
</p></description>
		</item>
		<item>
			<title>marcopaivaf on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142807</link>
			<pubDate>Mon, 06 Feb 2012 03:47:49 +0000</pubDate>
			<dc:creator>marcopaivaf</dc:creator>
			<guid isPermaLink="false">142807@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Sure!<br />
This is the HelloWorldLayer interface:</p>
<pre><code>// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
{
    NSMutableArray *enemyArray;

}

// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;
+(CGSize) getWinSize;
-(void)createEnemies;
-(void)destroyItemFromArray;

@end</code></pre>
<p>And this is my implementation code for the HelloWorldLayer:</p>
<pre><code>+(CCScene *) scene
{
	// &#039;scene&#039; is an autorelease object.
	CCScene *scene = [CCScene node];

	// &#039;layer&#039; is an autorelease object.
	HelloWorldLayer *layer = [HelloWorldLayer node];
	// add layer as a child to scene
	[scene addChild: layer];

	// return the scene
	return scene;
}

// on &#34;init&#34; you need to initialize your instance
-(id) init
{
	// always call &#34;super&#34; init
	// Apple recommends to re-assign &#34;self&#34; with the &#34;super&#34; return value
	if( (self=[super init])) {

        enemyArray = [[NSMutableArray alloc] init];

       [self createEnemies];

	}
	return self;
}

-(void)createEnemies{

    for(int i=0; i&#60;10; i++){

        Enemy *inimigo = [[Enemy alloc] initWithScene:self secound:&#039;c&#039;];
        [inimigo iniciar];
        [enemyArray addObject:inimigo];

    }

}

+(CGSize)getWinSize{
    // ask director the the window size
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    return winSize;
}

-(void)destroyItemFromArray{
    if(enemyArray == nil){
        NSLog(@&#34;THIS ARRAY IS NULL!&#34;);
    }
}</code></pre>
<p>Well, if i call destroyItemFromArray and any point after creating the enemies, i will give my that NSLog =(
</p></description>
		</item>
		<item>
			<title>winzz on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142806</link>
			<pubDate>Mon, 06 Feb 2012 03:40:23 +0000</pubDate>
			<dc:creator>winzz</dc:creator>
			<guid isPermaLink="false">142806@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>can you provide more code?
</p></description>
		</item>
		<item>
			<title>marcopaivaf on "NSMutableArray returnning 0 after adding objects and initialize!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28975#post-142805</link>
			<pubDate>Mon, 06 Feb 2012 03:33:51 +0000</pubDate>
			<dc:creator>marcopaivaf</dc:creator>
			<guid isPermaLink="false">142805@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everyone!</p>
<p>Im currently have a NSMutableArray that's declared at my interface, and at the init of my implementation, i do initialize it as array = [[NSMutableArray alloc] init];</p>
<p>so after i initialize my array, i call a method  that runs a for loop creating CCSprites and adding those inside my array;<br />
for(int i=0; i&#60;10; i++){</p>
<p>        Enemy *enemy = [[Enemy alloc] initWithScene:self secound:'c'];<br />
        [enemy iniciar];<br />
        [array addObject:enemy];<br />
}</p>
<p>Well, its all good if i put a NSLog inside that method to output the array count. But when i try to get the array count from another method i always get 0, or if i verify if the array is equal to nil, it always is.</p>
<p>i try to retain the array, but nothing seems to work.... does anyone could help me?
</p></description>
		</item>
		<item>
			<title>Birkemose on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142798</link>
			<pubDate>Mon, 06 Feb 2012 00:12:09 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142798@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Understanding memory management will save you at least 90% of you future problems, as long as you do not make it harder than it is.<br />
Using retained properties is both making it harder than it is, and utterly useless.
</p></description>
		</item>
		<item>
			<title>Achmes on "Video on iOS 3.2"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28972#post-142795</link>
			<pubDate>Sun, 05 Feb 2012 23:19:40 +0000</pubDate>
			<dc:creator>Achmes</dc:creator>
			<guid isPermaLink="false">142795@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey,</p>
<p>I've added video to my app this way:<br />
<pre><code>NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@&#34;play720&#34; ofType:@&#34;mp4&#34;]];
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

    // Register to receive a notification when the movie has finished playing.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayer];

    if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
        // Use the new 3.2 style API
        moviePlayer.controlStyle = MPMovieControlStyleNone;
        moviePlayer.shouldAutoplay = YES;

        CGSize winSize = [[CCDirector sharedDirector] winSize];
        moviePlayer.view.frame = CGRectMake(0, 0, winSize.width, winSize.height);	// width and height are swapped after rotation
        [[[CCDirector sharedDirector] openGLView] addSubview:moviePlayer.view];
    } else {
        // Use the old 2.0 style API
        moviePlayer.movieControlMode = MPMovieControlModeHidden;
        [moviePlayer play];</code></pre>
<p>It works fine on iPad 4.2+ Simulator, but when I try to launch it on iPad 3.2 Simulator, I got two allerts:<br />
"IOS Simulator could not find the SDK. The SDK may need to be reinstalled".<br />
"The simulated application quit."</p>
<p>How can I fix it? :(
</p></description>
		</item>
		<item>
			<title>toucansamurai on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142794</link>
			<pubDate>Sun, 05 Feb 2012 23:01:49 +0000</pubDate>
			<dc:creator>toucansamurai</dc:creator>
			<guid isPermaLink="false">142794@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Well that worked.  Thanks, Birkemose! I guess I have more reading to do on retaining and releasing -- I thought that just declaring an object as a property to a "running" class would keep it around, but apparently not. As soon as I put </p>
<pre><code>startPlaying = [NSDate date];
	[startPlaying retain];</code></pre>
<p>in when I first declared startPlaying, everything worked fine. I guess, as you say, the object itself was disappearing when the startGame method ended, so when Xcode went to find it in loseGame, EXC_BAD_ACCESS.</p>
<p>Not related to the way I am calling the GameScene class at all, I guess -- with that issue fixed, the layers seem to load and switch without a problem. Thanks everyone! I will read up more on memory management for the future.
</p></description>
		</item>
		<item>
			<title>Birkemose on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142789</link>
			<pubDate>Sun, 05 Feb 2012 22:45:28 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142789@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>As @<a href='http://www.cocos2d-iphone.org/forum/profile/62189'>LittleBitStudio</a> said, you are not retaining startPlaying.<br />
It expires when startGame exits, so no matter what you do, it will be a ghost when you access it in loseGame.
</p></description>
		</item>
		<item>
			<title>toucansamurai on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142788</link>
			<pubDate>Sun, 05 Feb 2012 22:34:18 +0000</pubDate>
			<dc:creator>toucansamurai</dc:creator>
			<guid isPermaLink="false">142788@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I set up startPlaying as a retained property, which I think should take care of keeping it in memory as needed. Still having the issue, though.</p>
<p>LBS, I looked through the API for CCLayer, but didn't see an +(id)scene; in there at all. Yes, all of these three layer classes are subclassed from CCLayer, and as you can see above, my best solution so far is just to query the sharedDirector for the running scene, and then run the methods from there.</p>
<p>I am also getting a few issues from Xcode (though they haven't stopped running the program like this EXC_BAD_ACCESS has) because I'm asking the sharedDirector for a CCScene, but typing it as my own GameScene class. GameScene is subclassed from CCScene, so it all still works, but Xcode doesn't like it -- I get the yellow exclamation marks on all the references like that. If you have ideas or can tell me where this +(id)scene is, I'll look that up, thanks!</p>
<p>Bananni, you're right -- I am using real time rather than game time (which means if I ever implement a pause screen or the user multitasks out, it'll count that time. But I decided this was the easiest way to do it to start. Once all of the menus work, I might rewrite it for just game time.</p>
<p>And the BackgroundLayer basically serves as a title screen -- it has a few CCLabelTTFs that pop up with the game's name, and then waits for a tap to actually run the startGame method. Then the BG layer is removed, and the actual game runs on the ForegroundLayer. I know now that those should probably be different scenes rather than layers, but I figured since I coded it this way already, I would try just using the different layers.</p>
<p>Still working on figuring this out, so any insight is still appreciated. Will post here if/when I've got it all set with what was wrong. Thanks!
</p></description>
		</item>
		<item>
			<title>Bananni on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142738</link>
			<pubDate>Sun, 05 Feb 2012 11:55:54 +0000</pubDate>
			<dc:creator>Bananni</dc:creator>
			<guid isPermaLink="false">142738@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>NSDate doesnt use the game related time, it uses the real time, better work with delta time from sheduler.<br />
Why you add a bg in your init method when you remove it in all your other methods?
</p></description>
		</item>
		<item>
			<title>LittleBitStudio on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142712</link>
			<pubDate>Sun, 05 Feb 2012 03:00:52 +0000</pubDate>
			<dc:creator>LittleBitStudio</dc:creator>
			<guid isPermaLink="false">142712@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You're not retaining the instance of the date:</p>
<pre><code>startPlaying = [NSDate date]; // this returns an autorelease instance</code></pre>
<p>Is this a CCLayer based class? I usually subclass CCLayer and then implement the +(id)scene; to return a CCScene with my custom layer added to it. If you do it that way as well, the CCDirector is going to return the CCScene for the runningScene and your CCLayer is likely a child of it. Meaning, you'll need to get to the instance of the CCLayer from the scenes children inorder to call into the loseGame method directly. I'm making assumptions ... sorry, if they're wrong. What is the base class for this and how are you launching it. Scott
</p></description>
		</item>
		<item>
			<title>toucansamurai on "Layers/variables causing EXC_BAD_ACCESS"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28948#post-142710</link>
			<pubDate>Sun, 05 Feb 2012 01:43:04 +0000</pubDate>
			<dc:creator>toucansamurai</dc:creator>
			<guid isPermaLink="false">142710@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey guys, I am a noob to both iOS and Cocos2D but I've figured out quite a bit of it and I'm almost done with this simple game I'm making. I'm running into an EXC_BAD_ACCESS error and I'm not sure what is wrong.</p>
<p>The way I've got my game laid out is that I use a series of layers -- there's an intro layer (which I called BackgroundLayer), a main game layer (ForegroundLayer), and a endgame (to show results) layer (EndgameLayer). There's a main GameScene that runs everything, and then when each layer is done doing what it needs to do, it calls back the main GameScene and runs a method on it that clears out the old layer and brings up the new one. Here's the main game scene:</p>
<pre><code>- (id)init
{
    self = [super init];
    if (self) {

		BackgroundLayer *backgroundLayer = [BackgroundLayer node];

		[self addChild:backgroundLayer z:-10];

    }

    return self;
}

- (void) startGame {

	[self removeAllChildrenWithCleanup:YES];

	startPlaying = [NSDate date];

	FrontLayer *frontLayer = [FrontLayer node];
	[self addChild:frontLayer z:-5];

}

- (void) loseGame {

	[self removeAllChildrenWithCleanup:YES];

	timePlayed = [startPlaying timeIntervalSinceNow]; // this is the line I comment out, see below

	EndgameLayer *endgameLayer = [EndgameLayer node];
	[self addChild:endgameLayer];

}</code></pre>
<p>As you can see, I also have a timer running that counts the seconds between when the game starts and when the endgame layer is called. Where I'm having an issue is in the actual gameplay layer: When the game ends, I call this code:</p>
<pre><code>if (** game ending conditions **) {

		self.isTouchEnabled = NO;

		GameScene *gameScene = [[CCDirector sharedDirector] runningScene];
		[gameScene loseGame]; //Program received signal: EXC_BAD_ACCESS here

	}</code></pre>
<p>I hoped that would call loseGame, which would clear out the layer and bring the game results up. It obviously does not.</p>
<p>Here's the craziest part: When I comment out the "timePlayed =" line, the code works. I believe I've done everything right in declaring it and implementing it, but it's possible that I'm missing something dumb, because I'm learning this stuff just now.  In case you need it, here's the relevant timePlayed code in EndgameLayer that uses that number:<br />
<pre><code>GameScene *current = [[CCDirector sharedDirector] runningScene];
		double timePassed = [current timePlayed];

		NSString *timeMessage = [[NSString alloc] initWithFormat:@&#34;time: %f seconds&#34;, timePassed];</code></pre>
<p>Any help is much appreciated.
</p></description>
		</item>
		<item>
			<title>holadev on "Crash Issue - Terminating and Restarting App From the Background"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22212#post-142490</link>
			<pubDate>Fri, 03 Feb 2012 11:39:19 +0000</pubDate>
			<dc:creator>holadev</dc:creator>
			<guid isPermaLink="false">142490@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Could you please tell us what is the solution? Your link doesn't work. Thanks.
</p></description>
		</item>

	</channel>
</rss>

