Objekt von NSMutableDictionary und zeigen Sie es in der UITableView

SETUP

Habe ich ein NSMutableDictionary von NSMutableDictionaries. Ich erstelle ein Wörterbuch gesucht für Begriffe, und jetzt will ich Sie anzeigen. Ich benutzte eine Methode (unten) kopieren Sie die Elemente, die den Suchbegriff in einem anderen Wörterbuch. Ich weiß, dass es kopieren, da kann ich drucken Sie das Wörterbuch und die Ergebnisse sehen. Auch die richtige Anzahl von Zeilen angezeigt, aber keine Daten in Ihnen. Ich habe die Methode, die Kopien der Wörterbuch, und was das Wörterbuch schaut gerne in das original-array und dem, was es sieht aus wie der neue array.

PROBLEM

Mein Verständnis ziehen Sie Elemente aus der NSDictionaires ist nicht korrekt. ich habe gelesen, mehrere Orte, und ich weiß, dass ich verwenden möchten objectforkey. Aber ich kann nicht herausfinden, wie man die Wörterbücher aus dem Hauptwörterbuch und Sie anzeigen.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}    
if (searching) {


 //ATTEMPT ONE
 //       NSDictionary *searchEmp = [copyListOfItems objectForKey:[copyListOfItems allkeys]];    
//       cell.textLabel.text = [[searchEmp objectForKey:kFULLNAME_TAG] objectAtIndex:indexPath.row];               

//ATTEMPT TWO     
    NSString *name = [[copyListOfItems allKeys] objectAtIndex: indexPath.row];
    NSString *value = [copyListOfItems objectForKey:path];

    cell.textLabel.text = [copyListOfItems objectForKey:value];




}else{

     NSDictionary *employee = [[self.orderedSections valueForKey:[[[self.orderedSections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];

cell.textLabel.text = [employee objectForKey:kFULLNAME_TAG]; 
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;

}

Dies ist die Methode, die ich verwendet, um zu kopieren von einem NSMutableDictionary zu einem anderen

for (NSDictionary *emp in employeeData)
{
    NSString *empName = [emp objectForKey:kFULLNAME_TAG]; 
    NSRange titleResultsRange = [empName rangeOfString:searchText options:NSCaseInsensitiveSearch];

    if (titleResultsRange.length > 0){
        NSLog(@"search result ---> %@" ,emp);
        [copyListOfItems setValue:emp forKey:empName];
    }

}

Dies ist die NSMutableDictionary bevor ich kopieren Sie Sie in die "copyListofItems"

2 012-02-27 17:24:44.399 USSContacts[14514:10d03] search result ---> {
0 = JO;
1 = "Zary Joon";
10 = "N/A";
11 = "N/A";
2 = Joon;
3 = Zary;
4 = "N/A";
5 = "N/A";
6 = "N/A";
7 = "[email protected]";
8 = "N/A";
9 = "N/A";
BUID = "N/A";
Department = "N/A";
EmployeeId = JONZ;
Extension = "N/A";
FirstName = Zary;
FullName = "Zachary Joon";
LastName = Joon;
Mobile = "N/A";
Shift = "N/A";
Supervisor = "N/A";
Title = "N/A";
email = "[email protected]";

}

Dem Wörterbuch, dass ich versuche, um die Anzeige in der UITableView sieht wie folgt aus. Es ist eine Kopie von den oben genannten.

<CFBasicHash 0x5c6aa10 [0x1175400]>{type = mutable dict, count = 1,

2 : <CFString 0x5c7cf20 [0x1175400]>{contents = "Zary Joon"} = <CFBasicHash  0x5c7d0a0 [0x1175400]>{type = mutable dict, count = 24,
0 : <CFString 0x7058790 [0x1175400]>{contents = "Shift"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
1 : <CFString 0x7054390 [0x1175400]>{contents = "Mobile"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
2 : <CFString 0x70543c0 [0x1175400]>{contents = "Title"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
 4 : <CFString 0x7058ed0 [0x1175400]>{contents = "10"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
6 : <CFString 0x7054330 [0x1175400]>{contents = "Supervisor"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
8 : <CFString 0x7058100 [0x1175400]>{contents = "FirstName"} = <CFString 0x5c7d2a0 [0x1175400]>{contents = "Zary"}
9 : <CFString 0x7058f80 [0x1175400]>{contents = "11"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
13 : <CFString 0x7051a70 [0x1175400]>{contents = "0"} = <CFString 0x5c7c100 [0x117500]>{contents = "J"}
14 : <CFString 0x7054370 [0x1175400]>{contents = "email"} = <CFString 0x5c7d2c0 [0x1175400]>{contents = "[email protected]"}
15 : <CFString 0x7059ba0 [0x1175400]>{contents = "BUID"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
16 : <CFString 0x7058120 [0x1175400]>{contents = "1"} = <CFString 0x5c7cf20 [0x1175400]>{contents = "Zary Joon"}
19 : <CFString 0x7058c40 [0x1175400]>{contents = "2"} = <CFString 0x7063630 [0x1175400]>{contents = "Joon"}
22 : <CFString 0x7059b60 [0x1175400]>{contents = "3"} = <CFString 0x5c7d2a0 [0x1175400]>{contents = "Zary"}
23 : <CFString 0x7059bc0 [0x1175400]>{contents = "Department"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
25 : <CFString 0x7059960 [0x1175400]>{contents = "4"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"
26 : <CFString 0x7058770 [0x1175400]>{contents = "LastName"} = <CFString 0x7063630 [0x1175400]>{contents = "Joon"}
28 : <CFString 0x70527b0 [0x1175400]>{contents = "5"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
30 : <CFString 0x7058750 [0x1175400]>{contents = "FullName"} = <CFString 0x5c7cf20 [0x1175400]>{contents = "Zary Joon"}
31 : <CFString 0x70527c0 [0x1175400]>{contents = "6"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
34 : <CFString 0x70527f0 [0x1175400]>{contents = "7"} = <CFString 0x5c7d2c0 [0x1175400]>{contents = "[email protected]"}
36 : <CFString 0x70543a0 [0x1175400]>{contents = "EmployeeId"} = <CFString 0x5c7c100 [0x1175400]>{contents = "J"}
37 : <CFString 0x70563a0 [0x1175400]>{contents = "8"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
38 : <CFString 0x70580e0 [0x1175400]>{contents = "Extension"} = <CFString 0x7059970 [0x1175400]>{contents = "N/A"}
40 : <CFString 0x70563c0 [0x1175400]>{contents = "9"} = <CFString 0x7059970     [0x1175400]>{contents = "N/A"}
}

Cany jemand erklären, warum es hat all die zusätzlichen Informationen, die nach dem kopieren?

InformationsquelleAutor zach | 2012-02-28
Schreibe einen Kommentar