NSMutableArray bekommen [__NSCFString count]: unrecognized selector geschickt Instanz

Ich brauche Hilfe...

Wenn ich versuche, um die Anzahl der Zellen für Abschnitt mit einem NSMutableArray, bekomme ich [__NSCFString count]: unrecognized selector geschickt Instanz 0x6d567e0

Dies geschieht, wenn ich "rows = [[searchProfile objectAtIndex:Abschnitt] Anzahl];"

Hier ist der code:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"1");
    //_________ Return the number of sections ________
    int sections =  0;

    if (tableView == self.tableView)
    {
        sections = 2;
    }
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        sections = [searchedProfile count];
    }
    return sections;
}


/* ------------------------------------------ Set The Number Of Cells for Each Section ------------------------------- */


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"2");

    //_________  Return the number of rows in the section. ________
    int rows = 0;

    if (tableView == self.tableView)
    {
        if (section == 0) {
            rows = userProfile.count;}
        else {
            rows = profiles.count;}
    }

    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        rows = [[searchedProfile objectAtIndex:section]count];
    }
    return rows;
}

Und die Methode, fügt strings in "searchedProfile" array:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    searchedKeys = [NSMutableArray array];
    searchedProfile = [NSMutableArray array];
    searchedData = [NSMutableDictionary dictionary];

    [searchedProfile removeAllObjects];
    [searchedData removeAllObjects];
    [searchedKeys removeAllObjects];


        NSDictionary *profile;

        for (profile in profiles)
        {
            NSString *birthname;
            NSString *currentname;
            NSString *photopath;
            NSDate *birthdate;

            for (birthname in profile)
            {
                birthname = [profile objectForKey:@"birthname"];
                currentname = [profile objectForKey:@"currentname"];
                photopath = [profile objectForKey:@"profilepic"];
                birthdate = [profile objectForKey:@"birthdate"];
                NSRange nameRange = [birthname rangeOfString:searchString options:NSCaseInsensitiveSearch];

                if (nameRange.location != NSNotFound)
                {
                    [searchedProfile addObject:birthname];
                    [searchedData setObject:birthname forKey:@"birthname"];
                    [searchedData setObject:currentname forKey:@"currentname"];
                    [searchedData setObject:photopath forKey:@"profilepic"];
                    [searchedData setObject:birthdate forKey:@"birthdate"];
                    if ([birthname isEqualToString:[profile objectForKey:@"birthname"]])
                        break;
                }
            }
        }
    NSLog(@"SEARCHED PROFILES: %@", searchedProfile);
    NSLog(@"SEARCHED DATA:%@", searchedData);
    NSLog(@"SEARCHED KEYS:%@", searchedKeys);
    NSLog(@"count test: %d", searchedProfile.count);
    return YES;
}

Danke !

InformationsquelleAutor Razvan | 2012-09-08

Schreibe einen Kommentar