can I store an id value in array of float type ?

Posted by srikanth rongali on Stack Overflow See other posts from Stack Overflow or by srikanth rongali
Published on 2010-04-01T10:16:45Z Indexed on 2010/04/01 11:13 UTC
Read the original article Hit count: 178

I used, for(id value in values) to get the value from an NSArray. Now I want to store it in 2 dimensional float array[][]. When I try to assign the values to array it is giving error:incompatible types in assignment. I tried to cast the value but I got error: pointer value used where a floating point value was expected. I need to store the values in an 2 dimensional array . How can I make it ? Thank You.

@implementation fromFileRead1
NSString *fileNameString;
int numberOfEnemies, numberOfValues;
-(id)init
{
    if( (self = [super init]) ) 
    {
        NSString *path = @"/Users/sridhar/Desktop/Projects/exampleOnFile2/enemyDetals.txt";
        NSString *contentsOfFile = [[NSString alloc] initWithContentsOfFile:path];
        NSArray *lines = [contentsOfFile componentsSeparatedByString:@"\n"]; 
        numberOfEnemies = [lines count];
        NSLog(@"The number of Lines: %d", numberOfEnemies);
        for (id line in lines)
        {
            NSLog(@"Line %@", line );
            NSString *string1 = line;
            NSArray *split1 = [string1 componentsSeparatedByString:@","];
            numberOfValues = [split1 count];
            NSLog(@"The number of values in Row: %d", numberOfValues);
            for (id value in split1)
            {
                NSLog(@"value %@", value);
                float value1;
                value1 = [split1 objectAtIndex:2]);
                NSLog(@"VAlue of Value1 at index 2: %f", value1 );
            }
        }
    }
    return self;
}
@end

In enemyDetal.txt I have

1,3,3
2,3,2.8
10,2,1.6

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about cocoa-touch