你可以用tableView数据源添加一个新类。与nesessary数据来启动它后阿努数据换款的呼叫[的tableView的setDataSource:]:(从两个视图控制器使用委托合作它们。)
// DataSourceAtoZ.h
#import <Foundation/Foundation.h>
#import "MallsViewController.h"
@interface DataSourceCategory : NSObject <UITableViewDataSource> {
NSMutableArray *data;
UITableView *tableView;
}
@property (nonatomic, retain) NSMutableArray *data;
- (id)initWithData:(NSMutableArray *)d;
@end
然后,在你的代码的任何地方,组成数据要在的tableView和设置数据源:
NSMutableArray *dt = [[NSMutableArray alloc] init];
for (int i = 0; i < [categories count]; i++) {
NSMutableArray *names = [[NSMutableArray alloc] init];
[names addObject:[[categories objectAtIndex:i] objectAtIndex:0]];
for (int j = 1; j < [[categories objectAtIndex:i] count]; j++) {
NSRange match = [[[categories objectAtIndex:i] objectAtIndex:j] rangeOfString:[params objectAtIndex:0]];
if (match.length != 0) {
[names addObject:[[categories objectAtIndex:i] objectAtIndex:j]];
}
}
[dt addObject:names];
[names release];
}
dsCategory = [[DataSourceCategory alloc] init];
dsCategory = [dsCategory initWithData:dt];
[dt release];