The app I'm working on plots a lot of GMSMarkers on a google map. It works perfectly fine in all other devices, except iPhone 5. I have subclassed GMSMarker and set an object id to the subclass. This is done so that I can add the markers to an NSSet and ensure there are only distinct markers that are plotted and no duplicates. The subclass is:
@implementation BYOMarker
-(BOOL)isEqual:(id)object
{
BYOMarker *otherMarker = (BYOMarker *)object;
if (self.objectID.intValue == otherMarker.objectID.intValue) {
return YES;
}
return NO;
}
-(NSUInteger)hash
{
return [self.objectID hash];
}
@end
The .h file
#import <GoogleMaps/GoogleMaps.h>
@interface BYOMarker : GMSMarker
@property (assign, nonatomic) NSNumber *objectID;
@end
The app is crashing at the return of the hash function with an EXC_BAD_ACCESS exception. I enabled Zombie objects and tried to print po marker.objectID when I'm setting the map object for the marker and I get the following error:
*** -[CFNumber respondsToSelector:]: message sent to deallocated instance 0x80416470
0x80416470
Any Help?! TIA
You have a memory management problem with your objectID
property. Don't use assign
for object pointer properties. Use strong
.
@property (strong, nonatomic) NSNumber *objectID;