Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:44:03+00:00 2026-06-03T20:44:03+00:00

I am creating a iOS plugin for unity3D. below is the code. How ever

  • 0

I am creating a iOS plugin for unity3D. below is the code. How ever it is bombing out when [regionMonitor startMonitor] function is called with EXC_BAD_EXCESS. According to internet posts it seems like a memory management error. Can anyone see what is the issue here. thanks.

“RegionMonitoringPlugin.h”

 #import <Foundation/Foundation.h>
 #import <CoreLocation/CoreLocation.h>


@interface RegionMonitoringPlugin : NSObject <CLLocationManagerDelegate>
{
    CLLocationManager *locationManager; 
}

-(void)leavingHomeNotify;
-(void)startMonitor:(float)latitude longitude:(float)longitude radius:(float)raduis;

@end

“RegionMonitoringPlugin.mm”

#import "RegionMonitoringPlugin.h"

@implementation RegionMonitoringPlugin

- (id) init
{
    if (self = [super init])
   {
      locationManager = [[[CLLocationManager alloc] init] autorelease];
      locationManager.delegate = self;
      [locationManager setDistanceFilter:kCLDistanceFilterNone];
      [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
   }
return self;
}

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    [self leavingHomeNotify];
}

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
    [self leavingHomeNotify];
}

 - (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)regionwithError:(NSError *)error
{
    NSLog(@"Location error %@, %@", error, @"Fill in the reason here");
}

-(void)leavingHomeNotify
{
UILocalNotification *note = [[UILocalNotification alloc] init];
note.alertBody= @"Region Left";
[[UIApplication sharedApplication] presentLocalNotificationNow:note];
[note release];
 }

 -(void)startMonitor:(float)latitude longitude:(float)longitude radius:(float)radius
 {
  CLLocationCoordinate2D home;
  home.latitude = latitude;
  home.longitude = longitude;
  CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:home radius:radius identifier:@"home"];
  [locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest];
  [region release];    
 }

@end

extern "C" {

    static RegionMonitoringPlugin *regionMonitor;

    // Unity callable function to start region monitoring
    BOOL _startRegionMonitoring(float m_latitude,float m_longitude, float m_radius)
    {
        if (![CLLocationManager regionMonitoringAvailable] || ![CLLocationManager regionMonitoringEnabled] )
            return NO;
        if (regionMonitor == nil){
            regionMonitor = [[[RegionMonitoringPlugin alloc]init ] autorelease];
        }
        [regionMonitor startMonitor:m_latitude longitude:m_longitude radius:m_radius];
        return YES;

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:44:04+00:00Added an answer on June 3, 2026 at 8:44 pm

    If I see it correctly, you should not autorelease locationManager and neither regionMonitor.

    Add a dealloc method where you release locationManager instead. The regionMonitor should be released once you stop the location monitoring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a static library for iOS and am trying to get code coverage
According to iOS's Using and Creating Error Objects , one can display a error
Problem : I am creating an iOS chat app using the XMPPFramework and an
I am currently creating an iOS app, which connects to a database and asynchronously
1)I am creating a ios app in which I have to scan a pool
I am creating a quiz style app for iOS using phonegap. The app allows
I'm creating an application for iOS 5 and I'm drawing some gradients. The following
I am in the process of creating a synthesiser for iOS. After playing around
I'm creating an app that tracks your elevation. Currently IOS is one of the
I am creating iOS app with in-app purchase feature in it. I created the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.