I could not understand where the memory is leaking in my code ?

Posted by srikanth rongali on Stack Overflow See other posts from Stack Overflow or by srikanth rongali
Published on 2010-05-15T12:17:50Z Indexed on 2010/05/15 12:24 UTC
Read the original article Hit count: 170

Filed under:
|

I have the following code. I do not understand the problem in it. Whenever I include this class in my class the code is going to infinite loop. I could not get where I am wrong. please help me. Just point the errors in the code.

#import "readFileData.h"
#import "DuelScreen.h"

@implementation readFileData

@synthesize enemyDescription, numberOfEnemies, numberOfValues;
@synthesize enemyIndex, numberOfEnemyGunDrawImages, numberOfEnemyGunFireImages,   numberOfEnemyDieImages;
@synthesize countDownSpeed, enemyGunDrawInterval, enemyGunFire, enemyRefire;
@synthesize enemyAccuracyProbability, enemyGunCoordinateX, enemyGunCoordinateY;


-(id)init
{

    if( (self = [super init]) )
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
        NSString *documentsDirectory = [paths objectAtIndex:0]; 
        NSString *path = [documentsDirectory stringByAppendingPathComponent:@"enemyDetals.txt"];

        NSString *contentsOfFile = [[NSString alloc ]initWithContentsOfFile:path];
        NSArray *lines = [contentsOfFile componentsSeparatedByString:@"#"]; 
        numberOfEnemies = [lines count];
        int nEnemy;
        nEnemy = 0;
        NSArray *eachEnemy=[[lines objectAtIndex:nEnemy] componentsSeparatedByString:@"^"];

        DuelScreen *enemyNumber1 = [[DuelScreen alloc] init];
        NSLog(@"tempCount value in: readFile: %d", enemyNumber1.tempCount);
        enemyIndex = enemyNumber1.tempCount - 1;


        countDownSpeed = [[eachEnemy objectAtIndex:0]intValue];
        enemyGunDrawInterval = [[eachEnemy objectAtIndex:1]floatValue];
        enemyGunFire = [[eachEnemy objectAtIndex:2]floatValue];
        enemyAccuracyProbability =  [[eachEnemy objectAtIndex:3]floatValue];
        enemyRefire = [[eachEnemy objectAtIndex:4]floatValue];
        numberOfEnemyGunDrawImages = [[eachEnemy objectAtIndex:5]intValue];
        numberOfEnemyGunFireImages = [[eachEnemy objectAtIndex:6]intValue];
        numberOfEnemyDieImages = [[eachEnemy objectAtIndex:7]intValue];
        enemyGunCoordinateX = [[eachEnemy objectAtIndex:8]floatValue];
        enemyGunCoordinateY = [[eachEnemy objectAtIndex:9]floatValue];
        enemyDescription = [eachEnemy objectAtIndex:10];



    }
    return self;

}

@end

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about cocos2d-iphone