# Is there a memory leak in here?

I'm newish to obj-c and I have some code that works, but I'm thinking I may be leaking memory as I have two retain statements and no release statements.

In both cases if I remove the retain I get a bad access error on [btPairedDevices count]

Am I doing this right or is there a better way?

//===================================================================================================
- (id)init
{
self = [super init];
if (self) {
indexDeviceSearch = 0;
// Grab a list of paired devices
btPairedDevices = [IOBluetoothDevice pairedDevices];
[btPairedDevices retain];
}

return self;
}

//===================================================================================================
{
if(IOBluetoothValidateHardwareWithDescription(nil, nil) != kIOReturnSuccess)
{
[NSApp terminate:self];
}

NSLog(@"Application up an running");

// Start our timer looking for paired phones
timerDeviceSearch = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(timerDeviceSearchFired)
userInfo:nil
repeats:YES];
}

//===================================================================================================
- (void) timerDeviceSearchFired
{
// Check out the device
if (indexDeviceSearch < [btPairedDevices count])
{
IOBluetoothDevice *device = [btPairedDevices objectAtIndex:indexDeviceSearch];
if ([device deviceClassMajor] == kBluetoothDeviceClassMajorPhone)
{
// Found a phone
}
}

// Update the list of devices just in case the use
// paired something while we are running
btPairedDevices = [IOBluetoothDevice pairedDevices];
[btPairedDevices retain];

// Inc the index
indexDeviceSearch++;
if (indexDeviceSearch >= [btPairedDevices count])
indexDeviceSearch = 0;
}

//===========================================================================================================================
{
NSEnumerator *enumerator;
IOBluetoothDevice *tmpDevice;

// Allocate our array of monitored devices
if(!btMonitoredDevices)
{
btMonitoredDevices = [[NSMutableArray alloc] initWithCapacity:1];
if(!btMonitoredDevices)
return(FALSE);
[btMonitoredDevices retain];
}

// Walk the devices in the array.
enumerator = [btMonitoredDevices objectEnumerator];
if(enumerator)
{
while((tmpDevice = [enumerator nextObject]))
{
{
return(FALSE);
}
}
}

// Add new device to array
NSLog(@"Monitoring new device: %@", [device nameOrAddress]);

You should definitely be releasing both btMonitoredDevices and btPairedDevices in the dealloc. But it appears that this is your appDelegate so it matters little outside of correctness. I'd do it anyhow.
You shouldn't need the retain on btMonitoredDevices since you're calling alloc on it. So you already have a retain count of one on it. By calling retain on it you actually have a retain count of two.
So to sum up make sure you're releasing both in your dealloc and get rid of the [btMonitedDecices retain]; and you should be good.