Hey guys, I apparently have a Autoreleasepool leak and i cannot find it for the life of me. I have used all of the instrument tools. Here is my code if anyone can help.
Code:
@implementation ChatCloudViewController
@synthesize map,zoomInButton,zoomOutButton,messageField,messageTableController,communicator,followToggle,settingsViewController,filterButton,settingsButton;
-(void)userGoingBackToPublicView{
NSLog(@"Dismissing privateMessageView to show the public view");
[self dismissModalViewControllerAnimated:YES];
}
-(void)messageSelected:(Message *)message{
NSLog(@"Message: %@ was selected",message.text);
PrivateMessageViewController* timer = [[PrivateMessageViewController alloc] initWithNibName:nil bundle:nil];
timer.delegate = self;
timer.theBio=message.bio;
timer.theName=message.name;
timer.theMsg=message.text;
timer.theLocation=message.location;
[self presentModalViewController:timer animated:YES];
}
-(IBAction)goBack
{
//NSLog(@"retainCount:%d", [communicator retainCount]);
//[communicator release];
//NSLog(@"retainCount:%d", [communicator retainCount]);
[self.communicator stopTimer];
[self dismissModalViewControllerAnimated:YES];
}
-(IBAction)zoomMapIn:(UIButton*)sender{
zoomLevel+=1;
if(zoomLevel==1){
zoomOutButton.hidden = NO;
}
if(zoomLevel>=19){
zoomLevel = 19;
zoomInButton.hidden = YES;
}
//NSLog([NSString stringWithFormat:@"zoomLevel:%d",zoomLevel]);
[self performZoom];
}
-(IBAction)zoomMapOut:(UIButton*)sender{
zoomLevel-=1;
if(zoomLevel==18){
zoomInButton.hidden = NO;
}
if(zoomLevel<=0){
zoomLevel = 0;
zoomOutButton.hidden = YES;
}
//NSLog([NSString stringWithFormat:@"zoomLevel:%d",zoomLevel]);
[self performZoom];
}
-(void)performZoom{
if(following){
[map setCenterCoordinate:map.userLocation.coordinate zoomLevel:zoomLevel animated:YES];
}
else{
[map setCenterCoordinate:map.centerCoordinate zoomLevel:zoomLevel animated:YES];
}
}
-(IBAction)showSettings{
NSLog(@"Pushing the settings view in response to user click settings");
[self presentModalViewController:settingsViewController animated:YES];
[settingsViewController release];
}
-(IBAction)performFilter:(UIButton*)sender{
float minLatitude = map.region.center.latitude - (map.region.span.latitudeDelta/2);
float maxLatitude = map.region.center.latitude + (map.region.span.latitudeDelta/2);
float minLongitude = map.region.center.longitude - (map.region.span.longitudeDelta/2);
float maxLongitude = map.region.center.longitude + (map.region.span.longitudeDelta/2);
NSLog(@"minlat:%f\nmaxlat:%f\nminlong:%f\nmaxlong:%f\n",minLatitude,maxLatitude,minLongitude,maxLongitude);
[messageTableController filterMessagesByMinLatitude:minLatitude
maxLatitude:maxLatitude
andMinLongitude:minLongitude
maxLongitude:maxLongitude];
}
-(NSMutableArray *)latitudeCalculator{
NSNumber *minLatitude = [NSNumber numberWithFloat:map.region.center.latitude - (map.region.span.latitudeDelta/2)];
NSNumber *maxLatitude = [NSNumber numberWithFloat:map.region.center.latitude + (map.region.span.latitudeDelta/2)];
NSNumber *minLongitude = [NSNumber numberWithFloat:map.region.center.longitude - (map.region.span.longitudeDelta/2)];
NSNumber *maxLongitude = [NSNumber numberWithFloat:map.region.center.longitude + (map.region.span.longitudeDelta/2)];
NSMutableArray *coordinates = [NSMutableArray array];
[coordinates addObject:minLatitude];
[coordinates addObject:maxLatitude];
[coordinates addObject:minLongitude];
[coordinates addObject:maxLongitude];
return coordinates;
}
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSString *msg = [[NSString alloc] initWithFormat:@"ALLOW THE BLUE DOT TO ZERO INTO YOUR POSITION. If you notice the chat room lagging or multiple posting, just press go back and reopen the room. This fixes the majority of the problems. If that doesnt fix it please contact us."];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Gamer Lounge"
message: msg
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
[msg release];
[super viewDidLoad];
locationController = [[ChatCloudLocationController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
map.mapType = MKMapTypeHybrid;
map.zoomEnabled=TRUE;
UITapGestureRecognizer* rec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchChangedWithGestureRecognizer)];
rec.numberOfTouchesRequired=2;
// set options for this recognizer.
[map addGestureRecognizer:rec];
[rec release];
following = NO;
mapOnlyView = NO;
audioController = [[ChatCloudAudioController alloc] init];
//[audioController release];
//NSLog(@"retainCount:%d", [communicator retainCount]);
//ChatCloudCommunicationController *comm =[[ChatCloudCommunicationController alloc] init];
[communicator startTimer];
}
-(void)touchChangedWithGestureRecognizer{
NSLog(@"User tapped the map view");
[messageField resignFirstResponder];
if([self interfaceOrientation]==UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation]==UIInterfaceOrientationLandscapeRight){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.2];
// Defaults to ease in and ease out [UIView setAnimationCurve
// also setAnimationDelay
// call a function when it is done
int direction;
if(mapOnlyView){
direction=-1;
}
else{
direction=1;
}
messageField.frame = CGRectOffset(messageField.frame,0,direction*150);
messageTableController.view.frame=CGRectOffset(messageTableController.view.frame, 0, direction*110);
zoomInButton.frame = CGRectOffset(zoomInButton.frame,0,direction*-62);
zoomOutButton.frame = CGRectOffset(zoomOutButton.frame,0,direction*-62);
settingsButton.frame = CGRectOffset(settingsButton.frame,0,direction*-62);
if(!mapOnlyView){
map.frame=CGRectMake(0, -20, 480, 320);
}
else{
map.frame=CGRectMake(0, -20, 480, 180);
}
[UIView commitAnimations];
mapOnlyView = !mapOnlyView;
}
}
- (void)messageUpdateComplete:(NSMutableArray *)newMessages{
NSLog(@"Communication Controller has sent a message update complete message");
for(int i=0;i<[newMessages count];i++){
[messageTableController addMessageToTable:[newMessages objectAtIndex:i]];
CLLocationCoordinate2D placemarkLocation;
Message *temp = [newMessages objectAtIndex:i];
placemarkLocation.latitude = temp.latitude;
placemarkLocation.longitude = temp.longitude;
placemark=[[PlaceMark alloc] initWithCoordinate:placemarkLocation title:temp.location subtitle:temp.text];
[map addAnnotation:placemark];
[placemark release];
//NEW
//[temp release];
}
}