numberofSections/numberofRows を返すのに問題があります。私はデータでいっぱいの辞書を持っています
-(void)setUpContacts{
//set up the contacts
NSString *string = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
letterArray = [[NSMutableDictionary alloc]init];
Contacts *contact = [[Contacts alloc]init];
contactNumbers = [contact phoneNumbers];
for (NSDictionary* info in contactNumbers) {
firstLetter = [info objectForKey:@"lastName"];
index = @"_";
if([firstLetter length] > 0){
firstLetter =[firstLetter substringToIndex:1];
firstLetter= [firstLetter capitalizedString];
NSRange range = [string rangeOfString:firstLetter];
if(range.length >= 0){
index= firstLetter;
}
}
if(![letterArray objectForKey:index]){
[letterArray setValue:[NSMutableArray array] forKey:index];
}
[[letterArray objectForKey:index] addObject:info];
}
NSLog(@"%@",letterArray);}
そしてこれでNSLogs
C = (
{
firstName = Alex;
kind = Mobile;
lastName = Chang;
name = "Alex Chang (Mobile)";
number = "(555) 555-5555";
},
{
firstName = YuYu;
kind = Mobile;
lastName = Chen;
name = "YuYu Chen (Mobile)";
number = "(408) 112-2334";
},
{
firstName = Chris;
kind = Mobile;
lastName = Choi;
name = "Chris Choi (Mobile)";
number = "(999) 999-9999";
},
{
firstName = Kevin;
kind = Mobile;
lastName = Chung;
name = "Kevin Chung (Mobile)";
number = "1 (231) 241-2312";
}
);
H = (
{
firstName = Danny;
kind = Mobile;
lastName = Huang;
name = "Danny Huang (Mobile)";
number = "(408) 599-9770";
},
{
firstName = Ice;
kind = Mobile;
lastName = Huang;
name = "Ice Huang (Mobile)";
number = "(408) 444-4444";
}
);
K = (
{
firstName = Will;
kind = Mobile;
lastName = King;
name = "Will King (Mobile)";
number = "(415) 123-4567";
}
);
L = (
{
firstName = "";
kind = iPhone;
lastName = LastName;
name = " LastName (iPhone)";
number = "(408) 123-2555";
},
{
firstName = david;
kind = Mobile;
lastName = lub;
name = "david lub (Mobile)";
number = "(666) 666-1111";
}
);
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; の場合 メソッド インデックスのセクション数を取得する方法;
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; メソッド、セクション内の行数を取得するにはどうすればよいですか?
編集
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *array = [letterArray mutableCopy];
return [[array objectAtIndex:section]count];}
そして、それは私にこのエラーを与えます: -[__NSCFDictionary objectAtIndex:]: 認識されないセレクターがインスタンス 0x8434cc0 に送信されました
前もって感謝します