私有方法定义不能在头文件中声明,否则编译时候会出现重复定义的错误。
@interface CallHistoryController(hidden)
- (NSMutableArray *)initCallHistory;
@end
@implementation CallHistoryController(hidden)
- (NSMutableArray *)initCallHistory
{
int ncount;
NSString *sql;
NSString *address,*initdate,*date,*flags;
TQSQLite *database = NULL;
NSMutableArray *historyArray = [[NSMutableArray alloc] init];
database = new TQSQLite(CALL_HISTORY);
if(database != NULL)
{
sql = [NSString stringWithFormat:@"Select address,date,flags From call Order By date Desc"];
ncount = database->query((char *)[sql UTF8String]);
for(int i = 0; i<ncount; i++)
{
address = [NSString stringWithUTF8String:database->queryData(i, 0)];
initdate = [NSString stringWithUTF8String:database->queryData(i, 1)];
flags = [NSString stringWithUTF8String:database->queryData(i, 2)];
/* Date format */
NSDate *dateSince = [NSDate dateWithTimeIntervalSince1970:[initdate doubleValue]];
NSString *time = [NSString stringWithFormat:@"%@", dateSince];
NSString *timeStr = [time substringFromIndex:5];
date = [timeStr substringToIndex:11];
NSArray * rowarry = [NSArray arrayWithObjects:address,date,flags,nil];
[historyArray addObject:rowarry];
}
}
delete database;
database = NULL;
return historyArray;
}
@end