Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Macman1993

macrumors 6502
Original poster
Nov 23, 2007
337
16
Not exactly what I am doing wrong here but I create an array of dictionaries from a .plist file and it appears to all work perfectly. I can access the files in it without any issues but when I try to call [array length] I get two warnings.

'NSArray' may not respond to '-length'
'Comparison between pointer and integer'

I cant tell what I am doing wrong here as I have called length a million times before. I am calling 'length' in a for loop, plugging the exact number by hand works but it will not always work since I can't know the size of the array in advance. Heres my code for initializing the array and the start of the for loop. Can someone please explain what I got wrong?

Code:
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString: @"http://web.suffieldacademy.org/~12clm/data.plist"]];
	
	
	NSArray *people = [dictionary valueForKey:@"People"];

	AppDelegate_Shared  *appDelegate =
	[[UIApplication sharedApplication] delegate];
	NSManagedObjectContext *context = [appDelegate managedObjectContext];
	NSError *error;

	//ISSUE HAPPENS HERE!!!!
	for (int i = 0;i<[people length]; i++) {

I have used breakpoints / other debug code and can verify that the line in question is what is causing the problem. When this line is run I get "SIGABRT" any help would be greatly appreciated.
 
It's not length. It's count. Make sure you read the sdk documentation, it would have quickly answered this.
 
...woops, sorry I have spent to much time on Java recently, when I looked through the documentation I read count but it never occurred to me that I mixed the two up.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.