Actually, NSFetchedResultsController is a little hard to understand.
You should try to process the UITableView data yourself. See the UITableViewDelegate protocol
Here are a few steps for you:
1) Create a class that inherits UITableViewDelegate and UITableViewDataSource
@interface YourTableViewController: UITableViewController<UITableViewDelegate,UITableViewDataSource>
2) Create an array in which your data will be stored.
@property (nonatomic,retain) NSMutableArray *data;
3) Perform the following methods:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DataObject *d=[data objectAtIndex:indexPath.row]; // selected data, now you can handle it } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return data.count; } - (UITableViewCell *)tableView:(UITableView *)mtableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString * ident=@ "CatalogCell"; UITableViewCell *cell=(UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:ident]; if (cell==nil) { cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident] autorelease]; } DataObject *d=[data objectAtIndex:indexPath.row]; [cell.textLabel setText:d.someField]; }
4) Select a method ( NSURLConnection , ASIHTTPRequest (sorry, only 2 hyperlinks are allowed for me) or others) to receive data from the server
-(void) parseData:(NSString *) d { NSArray * parsedData=[self someMethodToParseData:d]; [data setArray:parsedData]; [tableView reloadData]; }
source share