Note that there are some explanatory texts on larger screens.

plurals
  1. POnumberofSectionInTablesView/NumberofRowsInsection
    primarykey
    data
    text
    <p>I am having trouble returning the numberofSections/numberofRows. I have a dictionary full of data</p> <pre><code>-(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] &gt; 0){ firstLetter =[firstLetter substringToIndex:1]; firstLetter= [firstLetter capitalizedString]; NSRange range = [string rangeOfString:firstLetter]; if(range.length &gt;= 0){ index= firstLetter; } } if(![letterArray objectForKey:index]){ [letterArray setValue:[NSMutableArray array] forKey:index]; } [[letterArray objectForKey:index] addObject:info]; } NSLog(@"%@",letterArray);} </code></pre> <p>and it NSLogs with this</p> <pre><code>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"; } ); </code></pre> <p>for the -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; method how do i retrieve the number of sections for index;</p> <p>and for the -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; method, how do i retreive the number of rows in the section?</p> <h2>EDIT</h2> <pre><code>-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSArray *array = [letterArray mutableCopy]; return [[array objectAtIndex:section]count];} </code></pre> <p>and it gives me this error: -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8434cc0</p> <p>Thank you in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload