I have a structure, elements_table, in my iPhone app. I'm trying to use the following code to determine the number of rows in the function. However, when I use my function name, I get an "invalid receiver type" warning. I'm very new at this. Any help would be appreciated. Thanks.
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [elements_table count];
}
Your elements_table[2] is C struct, not Objective-C, and because of that it cant return [elements_table count]. You can add some variable to store it's count(now it 2, i think). Or if you don't need strong optimisation, you can use NSArray instead of struct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.