CocoaDev

Edit AllPages

I am fairly new to IOS Dev so please bear with me. I am using X Code 4, and I have tried to upgrade my project to IOS 5, although I think that has little to do with anything. I am calling an Odata Service that is returning data and I am calling [self.TableName reloadData]. The debugger does NOT get into the Cell Creation method…It just pops back out to the main application position and gives me a SigKill message or if I click on the arrow to keep debugging, I get the EXC_BAD_ACCESS method. I know I am probably autoreleasing wrong or incorrectly…I’ve seen notes on using Zombies, but I don’t think I enabled it correctly because it did not connect until I “attached to process” and pointed it at xcode. It looked like it was doing something, but I didn’t see anything that pointed to my bad objects…I have included my code below. Any help would be greatly appreciated.

thanks

mark

#import “CustomTalentSearchController.h” #import “CAEntities.h” #import “TalentDetailController.h”

@implementation CustomTalentSearchController

@synthesize talentSearchResults; @synthesize talentSearchResultsTable; @synthesize talentTitleTextField, talentAgentTextField, talentAgencyTextField; @synthesize searchProgressTimer, searchProgressView, searchTalentProgressLabel, searchResultCountLabel; @synthesize currentProgress;

-(void)showSearchProgress { self.searchProgressView.hidden = NO; self.searchTalentProgressLabel.hidden = NO; }

-(void)hideSearchProgress { self.searchProgressView.hidden = YES; self.searchTalentProgressLabel.hidden = YES; }

-(void)initiateSearchProgress { [self.searchProgressView setProgress:0.0]; [self showSearchProgress]; self.currentProgress = 0.0; }

-(void)startTimer { [self.searchProgressTimer invalidate]; self.searchProgressTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self selector: @selector(handleTimer:) userInfo: nil repeats: YES]; }

-(void)stopTimerAndProgressView { [self hideSearchProgress];

[self.searchProgressTimer invalidate];
self.searchProgressTimer = nil;

}

-(void)searchTalent:(NSDictionary *)args { //——————————— //Create a proxy to the service… //——————————— CAEntities *proxy; @try {

    proxy = [[CAEntities alloc] initWithUri:@"http://SERVERNAMEANDPORT/WCFODATASERVICE.svc/" credential:nil];
    
    
    //[self performSelectorOnMainThread:@selector(initiateSearchProgress) withObject:nil waitUntilDone:NO];
    //[self performSelectorOnMainThread:@selector(startTimer) withObject:nil waitUntilDone:NO];
    
    DataServiceQuery *qry = [proxy talents];
    
    //BUILDING A FILTER STRING FOR SEARCHING TALENT ON THE SERVER...
    NSMutableString* filterString = [NSMutableString stringWithString: @"substringof('"];
    
    NSString *searchName = [args objectForKey:@"searchName"];
    NSString *searchAgent = [args objectForKey:@"searchAgent"];
    NSString *searchAgency = [args objectForKey:@"searchAgency"];
    
    if([searchName length] > 0)
    {
        [filterString appendString: searchName];
        [filterString appendString:@"',name)"];
        
    }
    
    if([searchAgent length] > 0)
    {
        if([searchName length] > 0)
        {
            [filterString appendString:@" and substringof('"];
        }
        [filterString appendString: searchAgent];
        [filterString appendString:@"',Agent/name)"];
        
    }
    
    if([searchAgency length] > 0)
    {
        if([searchName length] > 0 || [searchAgent length] > 0)
        {
            [filterString appendString:@" and substringof('"];
        }
        [filterString appendString: searchAgency];
        [filterString appendString:@"',Agency/name)"];
    }
    
    [qry filter:filterString];
    //WHAT "substringof" looks like with multiple filters...
    //[qry filter:@"substringof('mark',name) and substringof('boo',name)"];
    
    [qry orderBy:@"name"];
    
    [qry expand:@"Credits/Show,Credits/Craft,Credits/Show/Genre,Credits/Show/Studio,Strengths/Genre,Agency,Agent"];
    
    QueryOperationResponse *result = [qry execute];
    
    self.talentSearchResults = result getResult] retain];
    
   //RELOAD THE TABLEVIEW DATA...
    [self.talentSearchResultsTable reloadData];
    self.searchResultCountLabel.text = [[[NSString stringWithFormat:@"%d", [talentSearchResults count]];
            
}
@catch(DataServiceRequestException *exception)
{
    [self showErrorMessage:exception];
}
@finally {
    //cleanup
    //REMMED OUT THE PROXY RELEASE TO SEE IF THAT WOULD HELP...IT DIDN'T...
    //[proxy release];
    
}

}

//NOT CALLING THIS METHOD CURRENTLY… -(void)loadSearchResults {

@try {
    if([talentSearchResults count] > 0)
    {
        //Have to refresh the Data in the Table...
        //self.talentSearchResults = searchResults;
        self talentSearchResultsTable] reloadData];
        self.searchResultCountLabel.text = [[[NSString stringWithFormat:@"%d", [talentSearchResults count]];
        
        [self stopTimerAndProgressView];
    }
    else
    {
        //Show Simple Alert to let Viewer know they need to search again...
        UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Message Center"
                                                            message:@"0 Search Results.  Please refine your search" delegate:self 
                                                  cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    }

}
@catch (NSException *exception) {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Message Center"
                                                        message:exception.reason delegate:self 
                                              cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];    
}
@finally 
{
    //nothing currently...
} }

-(void)showErrorMessage:(DataServiceRequestException )exception { NSString *errMessage = [exception reason]; //NSLog(errMessage); UIAlertView alertView = [[UIAlertView alloc] initWithTitle:@”Message Center” message:errMessage delegate:self cancelButtonTitle:@”OK” otherButtonTitles:nil]; [alertView show]; [alertView release];

[self stopTimerAndProgressView]; }

-(void)handleTimer:(NSTimer*)theTimer {

if(currentProgress < 1.0)
{
    currentProgress += .1;
    self.searchProgressView.progress = currentProgress;
}

}

//NOT USING THIS YET…USING THE ENTER KEY FOR SEARCHING CURRENTLY»» -(IBAction)searchButtonClicked { NSString *searchName = talentTitleTextField.text; NSString *searchAgent = talentAgentTextField.text; NSString *searchAgency = talentAgencyTextField.text;

NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys:
                      searchName, @"searchName",
                      searchAgent, @"searchAgent",
                      searchAgency, @"searchAgency",
                      nil];

[self performSelectorInBackground:@selector(searchTalent:) withObject:args];
//[self searchTalent];

}

//USING THIS METHOD TO SEARCH TALENT WHEN THE USER CLICKS THE ENTER KEY»»

}

#pragma mark - View lifecycle

#pragma mark - Table view delegate

//NOT GETTING THIS FAR YET…CODE BLOWS UP WHEN TRYING TO RENDER THE TABLEVIEW»»

}

@end


This is not a maiing list. It’s meant to be a library of helpful pages a la Wikipedia. Please read the rules and don’t pollute the wiki.