我想插入我的自定義對象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