Open the Roster header file
XMPPRoster.h
XMPPRosterCoreDataStorage.h Core Data storage
Defining Xmpproster global access for the Roster attribute module in AppDelegate.h
Defining the Xmpprostercoredatastorage data storage module in APPDELEGATE.M
To set up the roster and activate it under the Electronic Business Card module in the setup Xmppstream
2.3 _xmpprosterstorage = [[Xmpprostercoredatastorage alloc] init];
_xmpproster = [[Xmpproster alloc] initwithrosterstorage:_xmpprosterstorage];
3. Re-connect the module to Xmppstream
[_xmpproster Activate:_xmppstream];
4. Add an Agent
[_xmpproster adddelegate:self Delegatequeue:dispatch_get_global_queue (dispatch_queue_priority_default,0)];
Destroy Xmppstream and log out
{
1. Remove the agent
[_xmpproster removedelegate:self];
2. Deactivate
[_xmpproster deactivate];
4. Memory cleanup
_xmpproster = nil;
_xmpprosterstorage = nil;
}
To create a class, Rosterviewcontroller inherits Uitableviewcontroller to point the class of the roster to the classes to specify a reusable identifier identifier: Rostercell
Use XMPP Roster storage to import a coredata.framework framework
Using the Nsfetchedresultscontroller crawl result controller
Import <CoreData/CoreData.h> header files in. m files
and define a member variable Nsfetchedresultscontroller *_fetchedresultscontroller;
Number of table groupings
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView;
{
return _fetchedresultscontroller.sections.cont; Returns the number of query results
}
Number of rows in a table in the corresponding group
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{
Nsarray *sectiondata = [_fetchedresultscontroller sections];
if (sectiondata.count>0) {
ID <nsfetchedresultssectioninfo>sectioninfo = sectiondata[section];
return [Sectioninfo numberofobjects];
}
return 0;
}
Table Row Contents
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{
static NSString *id = @ "Rostercell"; ID is a table reusable identifier
UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:id Forindexpath:indexpath];
return cell;
Set cells
}
Instantiate Nsfetchedresultscontroller
-(void) setupfetchedcontroller{
0. If you want to do data access for CoreData, you can not do without nsmanagedobjectcontext
1. Instantiating Nsmanagedobjectcontext
2. Instantiating Nsfetchedresultscontroller
3. Querying data
}
8. Roster