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

beesbane

macrumors newbie
Original poster
Oct 16, 2010
21
0
I have a plist that is an array of dictionaries. I am loading it into a tableview and it is returning the same key ("name") in the list; which is good. Then each is pushed further through its navigationController and keeps passing the data, which is also good.

I need to be able to search through the list from its "name". Every example I've looked at that deals with searching is pulling its information from arrays, and I can't seem to correctly link my NSDictionary into the array and have it read.

Here is my library implementation file:
Code:
#import "dataLibrary.h"


@implementation dataLibrary

@synthesize theContent, thePlist;

// Gets a plist name and reads in its contents as an array
- (id)initWithLibraryName:(NSString *)libraryName {
    if (self = [super init]) {
        thePlist = libraryName;
        theContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:thePlist ofType:@"plist"]];
    }
    return self;
}

// [Safely] returns a "data" from the plist. Each item in the data source is a dictionary containing data about 
// the chosen data. 
- (NSDictionary *)libraryItemAtIndex:(int)index {
    return (theContent != nil && [theContent count] > 0 && index < [theContent count]) 
	? [theContent objectAtIndex:index]
	: nil;
}

// Returns the count of all datas in our library
- (int)libraryCount {
    return (theContent != nil) ? [theContent count] : 0;
}

- (void) dealloc {
    if (theContent) [theContent release];
    [super dealloc];
}


@end

And here is an array that is being passed into the current searching table:
Code:
listOfItems = [[NSMutableArray alloc] init];

NSArray *countriesArray = [NSArray arrayWithObjects:@"India", @"U.S.A", @"Germany", @"Turkey", @"France", nil];
	NSDictionary *countriesDict = [NSDictionary dictionaryWithObject:countriesArray forKey:@"Countries"];

[listOfItems addObject:countriesDict];

I've tried a few variations including my library with no avail. Please help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.