+(NSString*) getBaseURL {
NSUserDefaults *userSettings = [NSUserDefaults standardUserDefaults];
NSString* host = [userSettings stringForKey:@"host"];
NSString* port = [userSettings stringForKey:@"port"];
NSString* baseURL = [[NSString alloc] initWithFormat: @"http://%@:%@", host, port];
return baseURL;
}
Here you probably want the caller to retain the string if they wish, you are doing it for them here and it can cause leaks if not used properly, the way i w ould code this is by declaring autorelease for the baseURL so
NSString* baseURL = [[[NSString alloc] initWithFormat: @"http://%@:%@", host, port]autorelease];
return baseURL;
}
Here
+(NSString*) getChartURL:(int)width height:(int)height labels:(BOOL)labels time:(int)time monitorId:(NSString*)monitorId ruleInstanceId:(NSString*)ruleInstanceId {
NSString* returnURL;
if ([self isConfigured]){
NSString* suffix = [[NSString alloc] initWithFormat: @"/Mobile/ChartServlet?width=%d&height=%d&time=%d&monitor_id=%@&rule_instance_id=%@", width, height, time, monitorId, ruleInstanceId];
returnURL = [[self getBaseURL] stringByAppendingString:suffix];
} else {
if (width == 320) {
returnURL = @"http://Iphoneopt.bravehost.com/smallchart.png";
} else {
returnURL = [[NSString alloc] initWithFormat: @"http://Iphoneopt.bravehost.com/largechart%d.png", time];
labels = FALSE;
}
}
if (labels) {
NSString* labelsSuffix = [[NSString alloc] initWithFormat: @"&labels=%d", labels];
returnURL = [returnURL stringByAppendingString:labelsSuffix];
}
NSLog(@"returnURL=%@", returnURL);
return returnURL;
}
here you are not releasing any of the string you allocated, i suggest using [NSString stringWithFormat:] instead o f allocating them, but if you alloc them you must release them somewhere.