Sometimes two interfaces are required to pass the value. The Protocol method has been used before, but it is not very practical.
Nsicationicationcenter is suitable for transferring data on two interfaces.
Paste the method I wrote below
Accept. M-
Static accept * m_instance;
+ (Accept *) getinstance {
Return m_instance;
}
-(ID) initwithstyle :( uitableviewstyle) style {
// Override initwithstyle: If you create the Controller programmatically and want to perform customization that is not appropriate for viewdidload.
Self = [Super initwithstyle: style];
If (Self ){
// Custom initialization.
M_instance = self;
}
Return self;
}
-(Void) viewdidload {
[Super viewdidload];
[Self addeventlisteners];
}
-(Void) addeventlisteners
{
[[Nsicationcenter center defacenter center] addobserver: Self
Selector: @ selector (dealreceiveevent :)
Name: icationicationname
Object: Self];
}
-(Void) removeeventlisteners
{
[[Nsicationcenter center defacenter center] removeobserver: Self name: icationicationname object: Self];
}
-(Void) dealloc {
[Super dealloc];
[Self removeeventlisteners];
}
Sender. m
You can call the Doback method directly.
I have passed a cgpoint parameter here.
-(Void) Doback :( cgpoint) offset
{
If (m_curselecteditem! =-1 ){
Nsstring * curselected = [[nsstring alloc] initwithformat: @ "% d", m_curselecteditem];
Nsstring * m_offset = [[nsstring alloc] initwithformat: @ "% F", offset. x];
Nsmutabledictionary * DIC = [[nsmutabledictionary alloc] init];
[DIC setobject: curselected forkey: @ "1"];
[DIC setobject: m_offset forkey: @ "2"];
[[Nsicationicationcenter defacenter center] postnotificationname: notificationname
Object: [accept
Getinstance]