I am having some trouble populating a large plist into an array. Here is the snippet of code giving me problems:
// Populate the routes.
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"routes" ofType:@"plist"];
NSMutableArray *routes = [NSMutableArray arrayWithContentsOfFile:filePath];
NSLog(@"Routes: %@", routes);
// Populate the trips.
NSString *filePath2 = [[NSBundle mainBundle] pathForResource:@"trips" ofType:@"plist"];
NSMutableArray *trips = [NSMutableArray arrayWithContentsOfFile:filePath2];
NSLog(@"Trips: %@", trips);
My issue is that after displaying each mutable array in the logs, the log for the routes array displays just fine, but the log for the trips array simply doesn’t appear at all. Usually when an issue occurs then the log will show something like “Trips: ( )”, but that line doesn’t appear at all in this case. The only difference I can see between the two instances is that the routes plist is an array with about 1000 dictionary objects and the trips plist has nearly 92,000 objects. Is there some sort of limit on the size of plists?
Thanks in advance.
There isn’t a limit to to the size of plists, but there is a limit to the amount of data that you can feed to an
NSLog()command.If
tripswere actuallynil, theNSLog()call would succeed, and simply print out(null). Thetripsarray is populated, however, which is why it’s not printing out at all:NSLog()is saying, “sorry, there’s no way I’m going to let you to print out all that”.I believe this has likely changed in more recent versions of OS X due to possible security concerns or performance issues. (In the past, users’ hard drives would fill up with log files that were GB in size, caused by one process logging an error message hundreds of times a second; that is now limited to 500 logs per second). It’s kind of confusing why nothing is printed out and you get no feedback from Xcode or anything, but I guess the system has no way of knowing whether your use of
NSLog()is with good intentions or not.