Identify & mapView:didClickCalloutAccessoryButtonForGraphic

2687
5
08-03-2010 06:06 AM
JeffPapirtis
New Contributor III
Has anyone figured out the proper way to set up a table push with attributes after performing an Identify Task?

I have been able to do this with AGSQueryTask, but would like to know how I can acheive this using the Identify Task. 

My code reads as follows:

//when a user clicks the detail disclosure button on the call out
-(void)mapView:(AGSMapView *)mapView didClickCalloutAccessoryButtonForGraphic:(AGSGraphic *)graphic {

//lazily create the view for the feature details
    FeatureDetailsController *featureDetailViewController = [[FeatureDetailsController alloc] initWithNibName:@"FeaturesDetailViewController"
                                                                                                      bundle:nil];
if ([identifyPicker selectedRowInComponent:0] == 0){
    //give feature info to details view and push on to stack (i.e. make it visible)
featureDetailViewController.feature = graphic;
featureDetailViewController.displayFieldName = @"wellname";
    [self.navigationController pushViewController:featureDetailViewController animated:YES];
    [featureDetailViewController release];
}
}
//Creates the Graphics when an Item is selected.
- (void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results {

if ([identifyPicker selectedRowInComponent:0] == 0){
 
//Turn off network activity indicator
    [AGSMapView showNetworkActivityIndicator:FALSE];

    //clear previous results
    [self.graphicsLayer removeAllGraphics];
 
  wellViewInfoTemplate *wellTemplate =[[wellViewInfoTemplate alloc] init];

 
    //add new results

  AGSSymbol* symbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
  symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5];
  for (AGSIdentifyResult* result in results) {
   result.feature.symbol = symbol;
   result.feature.infoTemplate = wellTemplate;
   [self.graphicsLayer addGraphic:result.feature];
  }
  [self.graphicsLayer dataChanged];



featureDetailViewController.feature = graphic;
This seems to be the problem.  When it is commented out it pushes to the Tableview, but no attributes are present.  When it is not commented out as soon as I hit the graphic button the application will crash without any errors or exceptions.

So has anyone got any pointers for me, or solutions!  Any help would be greatly appreciated!
0 Kudos
5 Replies
HarikantJammi
New Contributor
Hi,
When your app crashes on the simulator without any error messages , this means that you are over releasing an object or you are calling a function or variable on a deallocated instance.

When you are going through such a scenario , do this

1) On Xcode top bar click on Project - > Edit Active Executable
2) Now you will get a window with two textboxes , the second textbox name is "Variables to be set in the environment"
3) Click on "+" button below , now you will have to add a new field
4) Now type the name entry as NSZombieEnabled and put its value as YES , ensure this entry is ticked
5) Clean your project and build, just before crash you will the object which is getting deallocated.

if u cant follow the above instructions just search for NSZombieEnabled in google 😛

I have not worked with identity results , but i can say that your graphics object whose reference u stored may be getting released.

Do something like this
AGSSymbol* symbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5];
for (AGSIdentifyResult* result in results) {
result.feature.symbol = symbol;
result.feature.infoTemplate = wellTemplate;
[self.graphicsLayer addGraphic:result.feature];
featureDetailViewController.feature = result.feature ; // try adding this statement in here
}
[self.graphicsLayer dataChanged];

Get back to me if u have any problems
Regards,
Harikant Jammi
0 Kudos
JeffPapirtis
New Contributor III
Hi,
When your app crashes on the simulator without any error messages , this means that you are over releasing an object or you are calling a function or variable on a deallocated instance.

When you are going through such a scenario , do this

1) On Xcode top bar click on Project - > Edit Active Executable
2) Now you will get a window with two textboxes , the second textbox name is "Variables to be set in the environment"
3) Click on "+" button below , now you will have to add a new field
4) Now type the name entry as NSZombieEnabled and put its value as YES , ensure this entry is ticked
5) Clean your project and build, just before crash you will the object which is getting deallocated.

if u cant follow the above instructions just search for NSZombieEnabled in google 😛

I have not worked with identity results , but i can say that your graphics object whose reference u stored may be getting released.

Do something like this
AGSSymbol* symbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5];
for (AGSIdentifyResult* result in results) {
result.feature.symbol = symbol;
result.feature.infoTemplate = wellTemplate;
[self.graphicsLayer addGraphic:result.feature];
featureDetailViewController.feature = result.feature ; // try adding this statement in here
}
[self.graphicsLayer dataChanged];

Get back to me if u have any problems
Regards,
Harikant Jammi


Thanks for your reply! 
After going through the steps you listed I have been able to learn that I have an Instance of AGSGraphic that somewhere is causing trouble.  I have been looking online through several threads but have not been able to trace it back to the root cause. 

This is the NSZombie that is returned.
-[AGSGraphic retain]: message sent to deallocated instance 0xb7556e0

I can not for the life of me locate where the issue is? 

I was also able to glean additional infomation going through the debugger. 
NSInvocation: warning: object 0x4ed9750 of class '_NSZombie_AGSGraphic' does not implement methodSignatureForSelector: -- trouble ahead

&
NSInvocation: warning: object 0x4ed9750 of class '_NSZombie_AGSGraphic' does not implement doesNotRecognizeSelector: -- abort

were both returned.  This has just been confusing me even more.

Any additional insight you can provide?  I am all ears! 

Thanks,
Jeff
0 Kudos
HarikantJammi
New Contributor
-[AGSGraphic retain]: message sent to deallocated instance 0xb7556e0

This means that the graphic object whose reference you were getting in the clickAccessory function got garbage collected, so its no more in existence. So when you were calling any message on that deallocated object , it crashed. So your object got prematurely released.

Why don't you comment out removeAllGraphics command in your code. Tell me if it crashes then.
If still you face a problem then I will have to take a look at your code. Fell free to contact me any time.
My email id is harikant_jammi@yahoo.co.in and IM is jvrgopal@gmail.com
0 Kudos
JeffPapirtis
New Contributor III
-[AGSGraphic retain]: message sent to deallocated instance 0xb7556e0

This means that the graphic object whose reference you were getting in the clickAccessory function got garbage collected, so its no more in existence. So when you were calling any message on that deallocated object , it crashed. So your object got prematurely released.

Why don't you comment out removeAllGraphics command in your code. Tell me if it crashes then.
If still you face a problem then I will have to take a look at your code. Fell free to contact me any time.
My email id is harikant_jammi@yahoo.co.in and IM is jvrgopal@gmail.com


It works!  after commenting out the remove graphics I can now pull up my tables in a table view.  But now I have a new problem, How do I remove the graphics that have been drawn?
is it as easy as creating a new IBAction?
-(IBAction)removeGraphics:(id)sender {
[self.graphicsLayer removeAllGraphics];
}

I have tried this in the past and had issues, as in nothing happened.

So now that I have the zombie figured out, what is the proper way to clear the graphics?

Again, Thanks for your help.  I am new to development work so any help I can get is really appreciated!
0 Kudos
HarikantJammi
New Contributor
It works!  after commenting out the remove graphics I can now pull up my tables in a table view.  But now I have a new problem, How do I remove the graphics that have been drawn?
is it as easy as creating a new IBAction?
-(IBAction)removeGraphics:(id)sender {
[self.graphicsLayer removeAllGraphics];
}

I have tried this in the past and had issues, as in nothing happened.

So now that I have the zombie figured out, what is the proper way to clear the graphics?

Again, Thanks for your help.  I am new to development work so any help I can get is really appreciated!


According to me, the placement of removeAllGraphics is wrong. I think you are using this command to fire your identity query

- (NSOperation *)executeWithParameters:(AGSIdentifyParameters *) params

Now put your removeAllGraphics in the line next to the above command or whatever command you are using to fire the identify query. Don't forget to add dataChanged after removing all graphics for redisplay.

Regards,
Harikant Jammi
0 Kudos