Let me introduce my functionality of App,I use push notification & addressbook and CoreTelephony
Framework.
What I am doing in my application is , When i get Push notification, I save the number from the Payload in a Appdelegate Variable(Incoming_NO) , if there is no Such contact with this number , Ill create the new contact and save it. When i receive the Call , the same contact name appears as i added before , Later on I am allowing the user to Edit the Contact if he want to save the contact or to delete , When he edit the contact and later when i receive the Push notification with same number I am getting the exc_bad_access to (Incoming_NO) I have enabled the Zombie and i got the breakpoint error at the same place ..
Can anyone help me what is the issue .
Received notification: {
aps = {
alert = "Please help me-+918884718240";
sound = "beep.caf";
};
}
Code :
NSString* alertValue = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
NSRange range=[alertValue rangeOfString:@":"];
NSString *param,*msg;
NSRange range1=[alertValue rangeOfString:@":"];
if (range1.location != NSNotFound)
{
param = [alertValue substringFromIndex:range1.location + range1.length];
msg=[alertValue substringToIndex:range.location + range.length-1];
}
else
{
range1=[alertValue rangeOfString:@"-"];
if (range1.location != NSNotFound)
{
param = [alertValue substringFromIndex:range1.location + range1.length];
msg=[alertValue substringToIndex:range1.location + range1.length-1];
}
}
if(range.length!=0)
{
parts= [NSMutableArray arrayWithArray:[alertValue componentsSeparatedByString:@":"]];
}else
{
parts = [NSMutableArray arrayWithArray:[alertValue componentsSeparatedByString:@"-"]];
}
incoming_Number =[parts objectAtIndex:1];
For this Variable(incoming_Number) I get the error when i receive the Push notification after saving the contact.
I tried to change incoming_Number type to NSString and NSMutableString , still the same error , I guess what happening is I am referring to the object which is released . But in debugger i can see it has the value .