我想插入我的自定义对象BalanceData
到NSMutableArray
,我得到一个错误:插入自定义对象的NSMutableArray
No known class method for selector 'balnce'
我的代码:
- (void)insertNewObject:(id)sender
{
if (!_balances) {
_balances = [[NSMutableArray alloc] init];
}
[_balances insertObject:[BalanceData balance] atIndex:0]; // error occures here
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
MasterViewController.m
顶部:
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "BalanceData.h"
@interface MasterViewController() {
NSMutableArray *_balances;
}
@end
@implementation MasterViewController
@synthesize balances = _balances;
我该如何正确使用它?
“balnce” - 它是错字只是在问题或你的代码呢? – Vladimir 2013-03-07 10:29:46
这不是一个错字。我敢打赌,我不明白这个代码。这是我第一次碰到Objective C. – hsz 2013-03-07 10:31:38
,这意味着你的代码中有拼写错误,你试图调用balnce方法而不是余额 – Vladimir 2013-03-07 10:36:17